From ab513918819e227187168222ca8a81dc996d89ca Mon Sep 17 00:00:00 2001 From: Tim Hochberg Date: Sun, 30 Apr 2006 21:46:36 +0000 Subject: Changed rundocs to closely follow procedure outlined in the docs for imp.load_module. This fixed a bizzare error where tests would run fine the first time through, but would fail the second time through when loading from a pyc file. --- numpy/testing/numpytest.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'numpy/testing/numpytest.py') diff --git a/numpy/testing/numpytest.py b/numpy/testing/numpytest.py index 211a1b581..eac58551b 100644 --- a/numpy/testing/numpytest.py +++ b/numpy/testing/numpytest.py @@ -176,7 +176,12 @@ class NumpyTestCase (unittest.TestCase): 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)) + path = [os.path.dirname(filename)] + file, pathname, description = imp.find_module(name, path) + try: + m = imp.load_module(name, file, pathname, description) + finally: + file.close() tests = doctest.DocTestFinder().find(m) runner = doctest.DocTestRunner(verbose=False) for test in tests: -- cgit v1.2.1