diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2006-04-26 22:51:40 +0000 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2006-04-26 22:51:40 +0000 |
commit | 3f682ff50232c35610ff885c6c1a7e3d400866d7 (patch) | |
tree | 9d6c956e9e93ece193af242ff1b6fe93b0ff94ce /numpy/testing/numpytest.py | |
parent | 7413032ea6011c74524aa5ecc384b2ae4964d6e9 (diff) | |
download | numpy-3f682ff50232c35610ff885c6c1a7e3d400866d7.tar.gz |
Added NumpyTestCase.rundocs method to support running doc-tests via unittest machinery - needed for running tests via testoob.
Diffstat (limited to 'numpy/testing/numpytest.py')
-rw-r--r-- | numpy/testing/numpytest.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/testing/numpytest.py b/numpy/testing/numpytest.py index 55e4e0fc8..211a1b581 100644 --- a/numpy/testing/numpytest.py +++ b/numpy/testing/numpytest.py @@ -168,6 +168,21 @@ class NumpyTestCase (unittest.TestCase): print>>sys.stdout, message sys.stdout.flush() + def rundocs(self, filename=None): + """ Run doc string tests found in filename. + """ + import doctest + if filename is None: + f = get_frame(1) + filename = f.f_globals['__file__'] + name = os.path.splitext(os.path.basename(filename))[0] + m = imp.load_module(name, open(filename), filename,('.py','U',1)) + tests = doctest.DocTestFinder().find(m) + runner = doctest.DocTestRunner(verbose=False) + for test in tests: + runner.run(test) + return + ScipyTestCase = NumpyTestCase def _get_all_method_names(cls): |