Skip to content

Commit c8822ab

Browse files
committed
Hide traceback of assert helpers
1 parent 952b9c3 commit c8822ab

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

array_api_tests/pytest_helpers.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import cmath
22
import math
3+
from functools import wraps
34
from inspect import getfullargspec
4-
from typing import Any, Dict, Optional, Sequence, Tuple, Union
5+
from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Union
56

67
from . import _array_module as xp
78
from . import dtype_helpers as dh
@@ -470,3 +471,18 @@ def assert_array_elements(
470471
assert xp.all(
471472
out == expected
472473
), f"{out_repr} not as expected {f_func}\n{out_repr}={out!r}\n{expected=}"
474+
475+
476+
def _make_wrapped_assert_helper(assert_helper: Callable) -> Callable:
477+
@wraps(assert_helper)
478+
def wrapped_assert_helper(*args, **kwargs):
479+
__tracebackhide__ = True
480+
assert_helper(*args, **kwargs)
481+
482+
return wrapped_assert_helper
483+
484+
485+
for func_name in __all__:
486+
if func_name.startswith("assert"):
487+
assert_helper = globals()[func_name]
488+
globals()[func_name] = _make_wrapped_assert_helper(assert_helper)

0 commit comments

Comments
 (0)