From 3401ff1883208f14f8b244e21f16e29a6353a0f0 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 7 Dec 2021 18:19:30 -0300 Subject: [PATCH] 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. --- src/_pytest/python_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 26f78c66a..cb72fde1e 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -101,6 +101,7 @@ class ApproxBase: ) def __bool__(self): + __tracebackhide__ = True raise AssertionError( "approx() is not supported in a boolean context.\nDid you mean: `assert a == approx(b)`?" )