-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
queryA question or suggestion that requires further informationA question or suggestion that requires further information
Description
A few times the idea of using direct assert
statements in tests rather than assert_
from numpy.testing
has come up. IIUC pytest
guarantees that assert
statements are executed.
Some advantages of assert
:
- Simplicity. No need for imports.
- Improved tracebacks.
pytest
has put work into makingassert
error messages readable for diagnosing problems. - Long-term consistency (?). I have seen a proliferation of
assert
statements in other packages, so that seems to be the zeitgeist. - Lowering contribution/review burden. Given the increasing use of
assert
, the probability of contributors using it assuming it's acceptable increases, and allowing its use is one fewer thing we have to nitpick.
Some advantages of numpy.testing.assert_
- Internal consistency (near-/medium-term). We have historically used
assert_
and have 1561 of instances according togit grep "assert_(" | wc -l
. - Guaranteed support.
numpy.testing
can be guaranteed to work as long asnumpy
does, whereasassert
relies onpytest
maintenance and/orpytest
-compatibleassert
support by any future testing framework.
There are probably others, feel free to comment and/or edit this top comment to keep track.
My +1 is for allowing assert
if people want to use it. I have begun moving a few of my other repos to follow this pattern and so far have found it beneficial.
Metadata
Metadata
Assignees
Labels
queryA question or suggestion that requires further informationA question or suggestion that requires further information