Common test support for all numpy test scripts.
This single module should provide all the common functionality for numpy tests in a single location, so that
can just import it and work right away. For background, see the
Asserts
(actual, desired[, rtol, ...])
Raises an AssertionError if two objects are not equal up to desired tolerance.
assert_array_almost_equal_nulp
(x, y[, nulp])
Compare two arrays relatively to their spacing.
(a, b[, maxulp, dtype])
Check that all items of arrays differ in at most N Units in the Last Place.
(actual, desired[, ...])
Raises an AssertionError if two array_like objects are not equal.
(x, y[, err_msg, verbose, ...])
Raises an AssertionError if two array_like objects are not ordered by less than.
(actual, desired[, err_msg, ...])
Raises an AssertionError if two objects are not equal.
(assert_raises)
Fail unless an exception of class exception_class is thrown by callable when invoked with arguments args and keyword arguments kwargs.
(exception_class, ...)
Fail unless an exception of class exception_class and with message that matches expected_regexp is thrown by callable when invoked with arguments args and keyword arguments kwargs.
(warning_class, *args, **kwargs)
Fail unless the given callable throws the specified warning.
(*args, **kwargs)
Fail if the given callable produces any warnings.
(*args, **kwargs)
Fail if the given callable produces any reference cycles.
(actual, desired)
Test if two strings are equal.
Asserts (not recommended)
It is recommended to use one of
,
assert_array_almost_equal_nulp
or
instead of these functions for more consistent floating point comparisons.
Decorators
Test running
Testing custom array containers (
)
These functions can be useful when testing custom array container implementations which make use of __array_ufunc__/__array_function__.
Guidelines
Running tests from inside Python
Running tests from the command line
Running tests in multiple threads
Other methods of running tests