Hide internal stack when using pytest.approx() in bool context

This makes the error traceback point directly to the offending usage, rather
than to the internal `Approx.__bool__` method.
This commit is contained in:
Bruno Oliveira 2021-12-07 18:19:30 -03:00
parent 4d7a962ca0
commit 3401ff1883
1 changed files with 1 additions and 0 deletions

View File

@ -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)`?"
) )