Skip to content

Commit

Permalink
Merge pull request #6224 from blueyed/visit_Assert-minor-cleanup
Browse files Browse the repository at this point in the history
minor: visit_Assert: move setting of `negation` out of branches
  • Loading branch information
blueyed committed Nov 19, 2019
2 parents 8d3e8b1 + f38f2d4 commit b820b7e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/_pytest/assertion/rewrite.py
Expand Up @@ -807,8 +807,9 @@ def visit_Assert(self, assert_):
)
)

negation = ast.UnaryOp(ast.Not(), top_condition)

if self.enable_assertion_pass_hook: # Experimental pytest_assertion_pass hook
negation = ast.UnaryOp(ast.Not(), top_condition)
msg = self.pop_format_context(ast.Str(explanation))

# Failed
Expand Down Expand Up @@ -860,7 +861,6 @@ def visit_Assert(self, assert_):
else: # Original assertion rewriting
# Create failure message.
body = self.expl_stmts
negation = ast.UnaryOp(ast.Not(), top_condition)
self.statements.append(ast.If(negation, body, []))
if assert_.msg:
assertmsg = self.helper("_format_assertmsg", assert_.msg)
Expand Down

0 comments on commit b820b7e

Please sign in to comment.