diff options
author | Alan McIntyre <alan.mcintyre@local> | 2008-06-17 02:17:34 +0000 |
---|---|---|
committer | Alan McIntyre <alan.mcintyre@local> | 2008-06-17 02:17:34 +0000 |
commit | 2bdd23ef6ddabcf24ef68f08fe7a737e4b52f355 (patch) | |
tree | e2a6f8f65cd88e8cfc5420f9a52fd80ed73f4cab /numpy/testing/nosetester.py | |
parent | 70974af863b99d49d9a1cf947afc019976e6b8b4 (diff) | |
download | numpy-2bdd23ef6ddabcf24ef68f08fe7a737e4b52f355.tar.gz |
Update README.txt to indicate nose version dependency, and port SciPy r4424 to NumPy
(prevent import of nose until actual execution of tests). Restored
"raises" function to numpy/testing/utils.py until it can be replaced with the function of
the same name from nose.tools after the lazy import.
Diffstat (limited to 'numpy/testing/nosetester.py')
-rw-r--r-- | numpy/testing/nosetester.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index e0a0aad3f..d35890446 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -7,7 +7,25 @@ import os import sys import re -import nose +def import_nose(): + """ Import nose only when needed. + """ + fine_nose = True + try: + import nose + from nose.tools import raises + except ImportError: + fine_nose = False + else: + nose_version = nose.__versioninfo__ + if nose_version[0] < 1 and nose_version[1] < 10: + fine_nose = False + + if not fine_nose: + raise ImportError('Need nose >=0.10 for tests - see ' + 'http://somethingaboutorange.com/mrl/projects/nose') + + return nose class NoseTester(object): """ Nose test runner. @@ -113,6 +131,7 @@ class NoseTester(object): doctests : boolean If True, run doctests in module, default False ''' + nose = import_nose() argv = self._test_argv(label, verbose, extra_argv) if doctests: argv+=['--with-doctest','--doctest-tests'] @@ -135,6 +154,7 @@ class NoseTester(object): ''' Run benchmarks for module using nose %(test_header)s''' + nose = import_nose() argv = self._test_argv(label, verbose, extra_argv) argv += ['--match', r'(?:^|[\\b_\\.%s-])[Bb]ench' % os.sep] nose.run(argv=argv) |