Skip to content

Commit 78cd1a0

Browse files
authored
Merge pull request #5140 from blueyed/rewrite-name
assertion rewriting: use actual helper name
2 parents 2b11b2c + adb8edb commit 78cd1a0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/_pytest/assertion/rewrite.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,12 @@ def assign(self, expr):
744744

745745
def display(self, expr):
746746
"""Call saferepr on the expression."""
747-
return self.helper("saferepr", expr)
747+
return self.helper("_saferepr", expr)
748748

749749
def helper(self, name, *args):
750750
"""Call a helper in this module."""
751751
py_name = ast.Name("@pytest_ar", ast.Load())
752-
attr = ast.Attribute(py_name, "_" + name, ast.Load())
752+
attr = ast.Attribute(py_name, name, ast.Load())
753753
return ast_Call(attr, list(args), [])
754754

755755
def builtin(self, name):
@@ -849,14 +849,14 @@ def visit_Assert(self, assert_):
849849
negation = ast.UnaryOp(ast.Not(), top_condition)
850850
self.statements.append(ast.If(negation, body, []))
851851
if assert_.msg:
852-
assertmsg = self.helper("format_assertmsg", assert_.msg)
852+
assertmsg = self.helper("_format_assertmsg", assert_.msg)
853853
explanation = "\n>assert " + explanation
854854
else:
855855
assertmsg = ast.Str("")
856856
explanation = "assert " + explanation
857857
template = ast.BinOp(assertmsg, ast.Add(), ast.Str(explanation))
858858
msg = self.pop_format_context(template)
859-
fmt = self.helper("format_explanation", msg)
859+
fmt = self.helper("_format_explanation", msg)
860860
err_name = ast.Name("AssertionError", ast.Load())
861861
exc = ast_Call(err_name, [fmt], [])
862862
if sys.version_info[0] >= 3:
@@ -906,7 +906,7 @@ def visit_Name(self, name):
906906
# _should_repr_global_name() thinks it's acceptable.
907907
locs = ast_Call(self.builtin("locals"), [], [])
908908
inlocs = ast.Compare(ast.Str(name.id), [ast.In()], [locs])
909-
dorepr = self.helper("should_repr_global_name", name)
909+
dorepr = self.helper("_should_repr_global_name", name)
910910
test = ast.BoolOp(ast.Or(), [inlocs, dorepr])
911911
expr = ast.IfExp(test, self.display(name), ast.Str(name.id))
912912
return name, self.explanation_param(expr)
@@ -942,7 +942,7 @@ def visit_BoolOp(self, boolop):
942942
self.statements = body = inner
943943
self.statements = save
944944
self.on_failure = fail_save
945-
expl_template = self.helper("format_boolop", expl_list, ast.Num(is_or))
945+
expl_template = self.helper("_format_boolop", expl_list, ast.Num(is_or))
946946
expl = self.pop_format_context(expl_template)
947947
return ast.Name(res_var, ast.Load()), self.explanation_param(expl)
948948

@@ -1067,7 +1067,7 @@ def visit_Compare(self, comp):
10671067
left_res, left_expl = next_res, next_expl
10681068
# Use pytest.assertion.util._reprcompare if that's available.
10691069
expl_call = self.helper(
1070-
"call_reprcompare",
1070+
"_call_reprcompare",
10711071
ast.Tuple(syms, ast.Load()),
10721072
ast.Tuple(load_names, ast.Load()),
10731073
ast.Tuple(expls, ast.Load()),

0 commit comments

Comments
 (0)