summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2008-10-03 02:11:50 +0000
committerCharles Harris <charlesr.harris@gmail.com>2008-10-03 02:11:50 +0000
commit7469d1afe2ee8c1c295bba131694f3731b9d092a (patch)
tree2a2a3ce23cb35ccf10c4e9a9330617416a34f6b2
parent823cda93ca2f19f96d01b7ea7fd8c951491302be (diff)
downloadnumpy-7469d1afe2ee8c1c295bba131694f3731b9d092a.tar.gz
Add assert_ to testing module. Use as assert_(condition, message).
This function does not disappear when python runs with the -OO option.
-rw-r--r--numpy/testing/utils.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index 35373734d..1157b256b 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -8,14 +8,19 @@ import re
import operator
from nosetester import import_nose
-__all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal',
- 'assert_array_equal', 'assert_array_less', 'assert_string_equal',
- 'assert_array_almost_equal', 'assert_raises', 'build_err_msg',
- 'decorate_methods', 'jiffies', 'memusage', 'print_assert_equal',
- 'raises', 'rand', 'rundocs', 'runstring', 'verbose']
+__all__ = ['assert_', 'assert_equal', 'assert_almost_equal',
+ 'assert_approx_equal', 'assert_array_equal', 'assert_array_less',
+ 'assert_string_equal', 'assert_array_almost_equal', 'assert_raises',
+ 'build_err_msg', 'decorate_methods', 'jiffies', 'memusage',
+ 'print_assert_equal', 'raises', 'rand', 'rundocs', 'runstring',
+ 'verbose']
verbose = 0
+def assert_(test, message=""):
+ if not test:
+ raise AssertionError(message)
+
def rand(*args):
"""Returns an array of random numbers with the given shape.