summaryrefslogtreecommitdiff
path: root/src/_pytest/assertion
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-11-18 20:26:31 +0100
committerDaniel Hahler <git@thequod.de>2019-11-18 23:21:00 +0100
commitf38f2d402e183130222993f501d92eefe0d398dc (patch)
tree634948cd5b77c4c72690d362c0db224873cea268 /src/_pytest/assertion
parent64d89105166264ad5169869bae8b945f542e7fb4 (diff)
downloadpytest-f38f2d402e183130222993f501d92eefe0d398dc.tar.gz
minor: visit_Assert: move setting of `negation` out of branches
Diffstat (limited to 'src/_pytest/assertion')
-rw-r--r--src/_pytest/assertion/rewrite.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py
index 2f9ca6de0..51ea1801b 100644
--- a/src/_pytest/assertion/rewrite.py
+++ b/src/_pytest/assertion/rewrite.py
@@ -807,8 +807,9 @@ class AssertionRewriter(ast.NodeVisitor):
)
)
+ 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
@@ -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)