diff options
author | Daniel Hahler <git@thequod.de> | 2019-11-18 20:26:31 +0100 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-11-18 23:21:00 +0100 |
commit | f38f2d402e183130222993f501d92eefe0d398dc (patch) | |
tree | 634948cd5b77c4c72690d362c0db224873cea268 /src/_pytest/assertion | |
parent | 64d89105166264ad5169869bae8b945f542e7fb4 (diff) | |
download | pytest-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.py | 4 |
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) |