Skip to content

Commit ac46609

Browse files
committed
Move assignment of format_variables with enable_assertion_pass_hook
1 parent ed1d1b1 commit ac46609

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/_pytest/assertion/rewrite.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,6 @@ def visit_Assert(self, assert_):
789789
self.variables = [] # type: List[str]
790790
self.variable_counter = itertools.count()
791791

792-
if self.enable_assertion_pass_hook:
793-
self.format_variables = [] # type: List[str]
794-
795792
self.stack = [] # type: List[Dict[str, ast.expr]]
796793
self.expl_stmts = [] # type: List[ast.stmt]
797794
self.push_format_context()
@@ -808,6 +805,7 @@ def visit_Assert(self, assert_):
808805
negation = ast.UnaryOp(ast.Not(), top_condition)
809806

810807
if self.enable_assertion_pass_hook: # Experimental pytest_assertion_pass hook
808+
self.format_variables = [] # type: List[str]
811809
msg = self.pop_format_context(ast.Str(explanation))
812810

813811
# Failed

0 commit comments

Comments
 (0)