Skip to content

Commit

Permalink
Move assignment of format_variables with enable_assertion_pass_hook
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Nov 18, 2019
1 parent ed1d1b1 commit ac46609
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/_pytest/assertion/rewrite.py
Expand Up @@ -789,9 +789,6 @@ def visit_Assert(self, assert_):
self.variables = [] # type: List[str]
self.variable_counter = itertools.count()

if self.enable_assertion_pass_hook:
self.format_variables = [] # type: List[str]

self.stack = [] # type: List[Dict[str, ast.expr]]
self.expl_stmts = [] # type: List[ast.stmt]
self.push_format_context()
Expand All @@ -808,6 +805,7 @@ def visit_Assert(self, assert_):
negation = ast.UnaryOp(ast.Not(), top_condition)

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

# Failed
Expand Down

0 comments on commit ac46609

Please sign in to comment.