-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
type: bugproblem that needs to be addressedproblem that needs to be addressed
Description
(From #5509 (comment))
It seems this patch fixes the problem:
diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py
index 8810c156c..28091c115 100644
--- a/src/_pytest/assertion/rewrite.py
+++ b/src/_pytest/assertion/rewrite.py
@@ -750,7 +750,7 @@ class AssertionRewriter(ast.NodeVisitor):
# Passed
fmt_pass = self.helper("_format_explanation", msg)
- orig = astor.to_source(assert_.test).rstrip("\n").lstrip("(").rstrip(")")
+ orig = astor.to_source(assert_.test).strip()
hook_call_pass = ast.Expr(
self.helper(
"_call_assertion_pass",item = <Function test>
lineno = 5
orig = f()
expl = 1
+ where 1 = f()
The test we have for it fails, but just because it expects the parenthesis to be stripped:
E and: '> raise Exception("Assertion Passed: {} {} at line {}".format(orig, expl, lineno))'
E and: 'E Exception: Assertion Passed: (a + b == c + d) (1 + 2) == (3 + 0) at line 7'
...
E remains unmatched: '*Assertion Passed: a + b == c + d (1 + 2) == (3 + 0) at line 7*'
So I think we should avoid trying to strip the results ourselves. I will open a PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: bugproblem that needs to be addressedproblem that needs to be addressed