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

Method visit_Name

src/_pytest/assertion/rewrite.py:978–986  ·  view source on GitHub ↗
(self, name: ast.Name)

Source from the content-addressed store, hash-verified

976 return name, self.explanation_param(expr)
977
978 def visit_Name(self, name: ast.Name) -> tuple[ast.Name, str]:
979 # Display the repr of the name if it's a local variable or
980 # _should_repr_global_name() thinks it's acceptable.
981 locs = ast.Call(self.builtin("locals"), [], [])
982 inlocs = ast.Compare(ast.Constant(name.id), [ast.In()], [locs])
983 dorepr = self.helper("_should_repr_global_name", name)
984 test = ast.BoolOp(ast.Or(), [inlocs, dorepr])
985 expr = ast.IfExp(test, self.display(name), ast.Constant(name.id))
986 return name, self.explanation_param(expr)
987
988 def visit_BoolOp(self, boolop: ast.BoolOp) -> tuple[ast.Name, str]:
989 res_var = self.variable()

Callers

nothing calls this directly

Calls 4

builtinMethod · 0.95
helperMethod · 0.95
displayMethod · 0.95
explanation_paramMethod · 0.95

Tested by

no test coverage detected