MCPcopy Create free account
hub / github.com/pytest-dev/pytest / push_format_context

Method push_format_context

src/_pytest/assertion/rewrite.py:807–818  ·  view source on GitHub ↗

Create a new formatting context. The format context is used for when an explanation wants to have a variable value formatted in the assertion message. In this case the value required can be added using .explanation_param(). Finally .pop_format_context() is used

(self)

Source from the content-addressed store, hash-verified

805 return "%(" + specifier + ")s"
806
807 def push_format_context(self) -> None:
808 """Create a new formatting context.
809
810 The format context is used for when an explanation wants to
811 have a variable value formatted in the assertion message. In
812 this case the value required can be added using
813 .explanation_param(). Finally .pop_format_context() is used
814 to format a string of %-formatted values as added by
815 .explanation_param().
816 """
817 self.explanation_specifiers: Dict[str, ast.expr] = {}
818 self.stack.append(self.explanation_specifiers)
819
820 def pop_format_context(self, expl_expr: ast.expr) -> ast.Name:
821 """Format the %-formatted string with current format context.

Callers 3

visit_AssertMethod · 0.95
visit_BoolOpMethod · 0.95
visit_CompareMethod · 0.95

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected