Skip to content

Commit 3ba9c01

Browse files
authored
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.
1 parent 4d7a962 commit 3ba9c01

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/_pytest/python_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def __eq__(self, actual) -> bool:
101101
)
102102

103103
def __bool__(self):
104+
__tracebackhide__ = True
104105
raise AssertionError(
105106
"approx() is not supported in a boolean context.\nDid you mean: `assert a == approx(b)`?"
106107
)

0 commit comments

Comments
 (0)