Skip to content

Commit f38f2d4

Browse files
committed
minor: visit_Assert: move setting of negation out of branches
1 parent 64d8910 commit f38f2d4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/_pytest/assertion/rewrite.py

Lines changed: 2 additions & 2 deletions
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)