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

Method visit_Call

src/_pytest/assertion/rewrite.py:1050–1081  ·  view source on GitHub ↗
(self, call: ast.Call)

Source from the content-addressed store, hash-verified

1048 return res, explanation
1049
1050 def visit_Call(self, call: ast.Call) -> tuple[ast.Name, str]:
1051 new_func, func_expl = self.visit(call.func)
1052 arg_expls = []
1053 new_args = []
1054 new_kwargs = []
1055 for arg in call.args:
1056 if isinstance(arg, ast.Name) and arg.id in self.variables_overwrite.get(
1057 self.scope, {}
1058 ):
1059 arg = self.variables_overwrite[self.scope][arg.id] # type:ignore[assignment]
1060 res, expl = self.visit(arg)
1061 arg_expls.append(expl)
1062 new_args.append(res)
1063 for keyword in call.keywords:
1064 match keyword.value:
1065 case ast.Name(id=id) if id in self.variables_overwrite.get(
1066 self.scope, {}
1067 ):
1068 keyword.value = self.variables_overwrite[self.scope][id] # type:ignore[assignment]
1069 res, expl = self.visit(keyword.value)
1070 new_kwargs.append(ast.keyword(keyword.arg, res))
1071 if keyword.arg:
1072 arg_expls.append(keyword.arg + "=" + expl)
1073 else: # **args have `arg` keywords with an .arg of None
1074 arg_expls.append("**" + expl)
1075
1076 expl = "{}({})".format(func_expl, ", ".join(arg_expls))
1077 new_call = ast.copy_location(ast.Call(new_func, new_args, new_kwargs), call)
1078 res = self.assign(new_call)
1079 res_expl = self.explanation_param(self.display(res))
1080 outer_expl = f"{res_expl}\n{{{res_expl} = {expl}\n}}"
1081 return res, outer_expl
1082
1083 def visit_Starred(self, starred: ast.Starred) -> tuple[ast.Starred, str]:
1084 # A Starred node can appear in a function call.

Callers

nothing calls this directly

Calls 8

assignMethod · 0.95
explanation_paramMethod · 0.95
displayMethod · 0.95
visitMethod · 0.80
appendMethod · 0.80
joinMethod · 0.80
getMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected