Skip to content

Commit b820b7e

Browse files
authored
Merge pull request pytest-dev#6224 from blueyed/visit_Assert-minor-cleanup
minor: visit_Assert: move setting of `negation` out of branches
2 parents 8d3e8b1 + f38f2d4 commit b820b7e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/_pytest/assertion/rewrite.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,9 @@ def visit_Assert(self, assert_):
807807
)
808808
)
809809

810+
negation = ast.UnaryOp(ast.Not(), top_condition)
811+
810812
if self.enable_assertion_pass_hook: # Experimental pytest_assertion_pass hook
811-
negation = ast.UnaryOp(ast.Not(), top_condition)
812813
msg = self.pop_format_context(ast.Str(explanation))
813814

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

0 commit comments

Comments
 (0)