Skip to content

ENH: testing: hiding assertion internals in pytest traceback #781

Merged
lucascolley merged 1 commit into
data-apis:mainfrom
prady0t:error-trace
Jun 9, 2026
Merged

ENH: testing: hiding assertion internals in pytest traceback #781
lucascolley merged 1 commit into
data-apis:mainfrom
prady0t:error-trace

Conversation

@prady0t

@prady0t prady0t commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #780

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>

@lucascolley lucascolley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Pradyot!

Perhaps you could give this a quick test @ntessore?

@lucascolley lucascolley added this to the 0.11.0 milestone Jun 9, 2026
@lucascolley lucascolley added enhancement New feature or request xpx.testing labels Jun 9, 2026
@lucascolley

Copy link
Copy Markdown
Member

confirmed that the xpx.testing frames are skipped:

In [3]: xpt.assert_equal(np.asarray(0), np.asarray(1))
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 xpt.assert_equal(np.asarray(0), np.asarray(1))

    [... skipping hidden 2 frame]

File ~/ghq/github.com/data-apis/array-api-extra/.pixi/envs/dev/lib/python3.14/site-packages/numpy/testing/_private/utils.py:919, in assert_array_compare(comparison, x, y, err_msg, verbose, header, precision, equal_nan, equal_inf, strict, names)
    914         err_msg += '\n' + '\n'.join(remarks)
    915         msg = build_err_msg([ox, oy], err_msg,
    916                             verbose=verbose, header=header,
    917                             names=names,
    918                             precision=precision)
--> 919         raise AssertionError(msg)
    920 except ValueError:
    921     import traceback

AssertionError:
Arrays are not equal

Mismatched elements: 1 / 1 (100%)
Max absolute difference among violations: 1
Max relative difference among violations: 1.
 ACTUAL: array(0)
 DESIRED: array(1)

@lucascolley lucascolley merged commit 28faf60 into data-apis:main Jun 9, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request xpx.testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: testing: hide assertion internals in pytest traceback

2 participants