MCPcopy
hub / github.com/pytest-dev/pytest / push_format_context

Method push_format_context

src/_pytest/assertion/rewrite.py:806–817  ·  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

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