diff options
-rw-r--r-- | numpy/lib/tests/test_polynomial.py | 5 | ||||
-rw-r--r-- | numpy/lib/tests/test_ufunclike.py | 7 | ||||
-rw-r--r-- | numpy/testing/numpytest.py | 15 |
3 files changed, 20 insertions, 7 deletions
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py index dac4d866f..75fcaecfb 100644 --- a/numpy/lib/tests/test_polynomial.py +++ b/numpy/lib/tests/test_polynomial.py @@ -75,9 +75,8 @@ poly1d([ 2.]) from numpy.testing import * -import doctest -def test_suite(level=1): - return doctest.DocTestSuite() +class test_docs(NumpyTestCase): + def check_doctests(self): return self.rundocs() if __name__ == "__main__": ScipyTest().run() diff --git a/numpy/lib/tests/test_ufunclike.py b/numpy/lib/tests/test_ufunclike.py index 5934aa23d..a28048342 100644 --- a/numpy/lib/tests/test_ufunclike.py +++ b/numpy/lib/tests/test_ufunclike.py @@ -55,9 +55,8 @@ array([ 2.169925 , 1.20163386, 2.70043972]) from numpy.testing import * -import doctest -def test_suite(level=1): - return doctest.DocTestSuite() +class test_docs(NumpyTestCase): + def check_doctests(self): return self.rundocs() if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() 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): |