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

Method assign

src/_pytest/assertion/rewrite.py:773–777  ·  view source on GitHub ↗

Give *expr* a name.

(self, expr: ast.expr)

Source from the content-addressed store, hash-verified

771 return name
772
773 def assign(self, expr: ast.expr) -> ast.Name:
774 """Give *expr* a name."""
775 name = self.variable()
776 self.statements.append(ast.Assign([ast.Name(name, ast.Store())], expr))
777 return ast.copy_location(ast.Name(name, ast.Load()), expr)
778
779 def display(self, expr: ast.expr) -> ast.expr:
780 """Call saferepr on the expression."""

Callers 6

generic_visitMethod · 0.95
visit_BoolOpMethod · 0.95
visit_UnaryOpMethod · 0.95
visit_BinOpMethod · 0.95
visit_CallMethod · 0.95
visit_AttributeMethod · 0.95

Calls 2

variableMethod · 0.95
appendMethod · 0.80

Tested by

no test coverage detected