Hide internal stack when using pytest.approx() in bool context (#9394)
This makes the error traceback point directly to the offending usage, rather
than to the internal `Approx.__bool__` method.
(cherry picked from commit 3ba9c01f9b
)
This commit is contained in:
parent
ac0870ebad
commit
76e108d06c
|
@ -101,6 +101,7 @@ class ApproxBase:
|
||||||
)
|
)
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
|
__tracebackhide__ = True
|
||||||
raise AssertionError(
|
raise AssertionError(
|
||||||
"approx() is not supported in a boolean context.\nDid you mean: `assert a == approx(b)`?"
|
"approx() is not supported in a boolean context.\nDid you mean: `assert a == approx(b)`?"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue