[Numpy-svn] r5379 - trunk/numpy/testing
numpy-svn at scipy.org
numpy-svn at scipy.org
Wed Jul 9 16:07:31 EDT 2008
Author: alan.mcintyre
Date: 2008-07-09 15:07:25 -0500 (Wed, 09 Jul 2008)
New Revision: 5379
Modified:
trunk/numpy/testing/nosetester.py
Log:
Updated doctest for NoseTester to reflect actual usage, and added
__file__ = '__main__' to doctest context to allow the updated test to
run correctly.
Added setupscons.py and setup.py to the list of files to ignore when
looking for doctests.
Cleaned up docstrings for readability.
Modified: trunk/numpy/testing/nosetester.py
===================================================================
--- trunk/numpy/testing/nosetester.py 2008-07-09 11:24:45 UTC (rev 5378)
+++ trunk/numpy/testing/nosetester.py 2008-07-09 20:07:25 UTC (rev 5379)
@@ -89,7 +89,12 @@
# Each doctest should execute in an environment equivalent to
# starting Python and executing "import numpy as np"
+ #
+ # Note: __file__ allows the doctest in NoseTester to run
+ # without producing an error
test.globs = {'__builtins__':__builtins__,
+ '__file__':'__main__',
+ '__name__':'__main__',
'np':numpy}
# always use whitespace and ellipsis options
@@ -112,7 +117,8 @@
# so that we can ignore NumPy-specific build files that shouldn't
# be searched for tests
old_wantFile = npd.Doctest.wantFile
- ignore_files = ['generate_numpy_api.py', 'scons_support.py']
+ ignore_files = ['generate_numpy_api.py', 'scons_support.py',
+ 'setupscons.py', 'setup.py']
def wantFile(self, file):
bn = os.path.basename(file)
if bn in ignore_files:
@@ -161,16 +167,17 @@
Usage: NoseTester(<package>).test()
<package> is package path or module Default for package is None. A
- value of None finds calling module path.
+ value of None finds the calling module path.
- Typical call is from module __init__, and corresponds to this:
+ This class is made available as numpy.testing.Tester, and a test function
+ is typically added to a package's __init__.py like so:
- >>> test = NoseTester().test
+ >>> from numpy.testing import Tester
+ >>> test = Tester().test
- This class is made available as numpy.testing.Tester:
+ Calling this test function finds and runs all tests associated with the
+ package and all its subpackages.
- >>> from numpy.testing import Tester
- >>> test = Tester().test
"""
def __init__(self, package=None):
More information about the Numpy-svn
mailing list