Merge pull request #6224 from blueyed/visit_Assert-minor-cleanup

minor: visit_Assert: move setting of `negation` out of branches
This commit is contained in:
Daniel Hahler 2019-11-19 01:11:53 +01:00 committed by GitHub
commit b820b7e384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -807,8 +807,9 @@ class AssertionRewriter(ast.NodeVisitor):
)
)
if self.enable_assertion_pass_hook: # Experimental pytest_assertion_pass hook
negation = ast.UnaryOp(ast.Not(), top_condition)
if self.enable_assertion_pass_hook: # Experimental pytest_assertion_pass hook
msg = self.pop_format_context(ast.Str(explanation))
# Failed
@ -860,7 +861,6 @@ class AssertionRewriter(ast.NodeVisitor):
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)