[Scipy-svn] r3827 - trunk/scipy/testing
scipy-svn@scip...
scipy-svn@scip...
Sat Jan 12 15:04:59 CST 2008
Author: matthew.brett@gmail.com
Date: 2008-01-12 15:04:55 -0600 (Sat, 12 Jan 2008)
New Revision: 3827
Modified:
trunk/scipy/testing/__init__.py
trunk/scipy/testing/nosetester.py
trunk/scipy/testing/nulltester.py
trunk/scipy/testing/pkgtester.py
Log:
nose testing docstrings, enabled scipy import without nose
Modified: trunk/scipy/testing/__init__.py
===================================================================
--- trunk/scipy/testing/__init__.py 2008-01-12 15:41:27 UTC (rev 3826)
+++ trunk/scipy/testing/__init__.py 2008-01-12 21:04:55 UTC (rev 3827)
@@ -11,8 +11,7 @@
try:
import nose
except ImportError:
- print 'Need nose testing framework installed for scipy tests'
- raise
+ pass
import decorators as dec
from numpy.testing.utils import *
Modified: trunk/scipy/testing/nosetester.py
===================================================================
--- trunk/scipy/testing/nosetester.py 2008-01-12 15:41:27 UTC (rev 3826)
+++ trunk/scipy/testing/nosetester.py 2008-01-12 21:04:55 UTC (rev 3827)
@@ -1,17 +1,46 @@
-''' Nose tester object '''
+''' Nose test running
+
+Implements .test functions for modules.
+
+'''
import os
import sys
import nose
class NoseTester(object):
- """ Scipy nose test runner.
+ """ Nose test runner.
Usage: NoseTester(<package>).test()
+
+ <package> is package path or module Default for package is None. A
+ value of None finds calling module path.
- <package> is package path or module - None finds calling module path
+ Typical call is from module __init__, and corresponds to this:
+
+ >>> test = NoseTester().test
+
+ In practice, because nose may not be importable, the __init__
+ files actually have:
+
+ >>> from scipy.testing.pkgtester import Tester
+ >>> test = Tester().test
+
+ The pkgtester module checks for the presence of nose on the path,
+ returning this class if nose is present, and a null class
+ otherwise.
"""
def __init__(self, package=None):
+ ''' Test class init
+
+ Parameters
+ ----------
+ package : string or module
+ If string, gives full path to package
+ If None, extract calling module path
+ Default is None
+
+ '''
if package is None:
f = sys._getframe(1)
package = f.f_locals.get('__file__', None)
@@ -21,31 +50,40 @@
package = os.path.dirname(package.__file__)
self.package_path = package
- def test(self, labels='fast', verbose=1, doctests=False, extra_argv=None):
+ def test(self, label='fast', verbose=1, doctests=False, extra_argv=None):
''' Module testing function
- labels - identifies tests to run. This can be a string to
- pass to the nosetests executable with the '-A'
- option, or one of several special values.
- Special values are:
- 'fast' - the default - which corresponds to
- nosetests -A option of
- 'not slow and not bench and not willfail'.
- 'full' - fast (as above) and slow tests as in
- nosetests -A option of 'not bench and not willfail'.
- None or '' - run all tests and benchmarks
-
- verbose - verbosity value 1-10
- doctests - if True, run doctests in module
- extra_argv - list with any extra args to pass to nosetest
+ Parameters
+ ----------
+ label : {'fast', 'full', '', attribute identifer}
+ Identifies tests to run. This can be a string to pass to
+ the nosetests executable with the'-A' option, or one of
+ several special values.
+ Special values are:
+ 'fast' - the default - which corresponds to
+ nosetests -A option of
+ 'not slow and not bench and not willfail'.
+ 'full' - fast (as above) and slow tests as in
+ nosetests -A option of 'not bench and not willfail'.
+ None or '' - run all tests and benchmarks
+ attribute_identifier - string passed directly to
+ nosetests as '-A'
+ verbose : integer
+ verbosity value for test outputs, 1-10
+ doctests : boolean
+ If True, run doctests in module, default False
+ extra_argv : list
+ List with any extra args to pass to nosetests
'''
argv = ['scipy module test', self.package_path, '-s']
- if labels:
- if labels == 'fast':
- labels = 'not slow and not bench and not willfail'
- elif labels == 'full':
- labels = 'not bench and not willfail'
- argv += ['-A', labels]
+ if label:
+ if not isinstance(label, basestring):
+ raise TypeError, 'Test selection label should be a string'
+ if label == 'fast':
+ label = 'not slow and not bench and not willfail'
+ elif label == 'full':
+ label = 'not bench and not willfail'
+ argv += ['-A', label]
argv += ['--verbosity', str(verbose)]
if doctests:
argv+=['--with-doctest']
Modified: trunk/scipy/testing/nulltester.py
===================================================================
--- trunk/scipy/testing/nulltester.py 2008-01-12 15:41:27 UTC (rev 3826)
+++ trunk/scipy/testing/nulltester.py 2008-01-12 21:04:55 UTC (rev 3827)
@@ -1,8 +1,16 @@
-''' Null tester (when nose not importable '''
+''' Null tester (when nose not importable)
+Merely returns error reporting lack of nose package
+
+See pkgtester, nosetester modules
+
+'''
+
+nose_url = 'http://somethingaboutorange.com/mrl/projects/nose'
+
class NullTester(object):
def __init__(self, *args, **kwargs):
pass
def test(self, labels=None, *args, **kwargs):
- raise ImportError, 'Need nose testing on path for tests'
+ raise ImportError, 'Need nose for tests - see %s' % nose_url
Modified: trunk/scipy/testing/pkgtester.py
===================================================================
--- trunk/scipy/testing/pkgtester.py 2008-01-12 15:41:27 UTC (rev 3826)
+++ trunk/scipy/testing/pkgtester.py 2008-01-12 21:04:55 UTC (rev 3827)
@@ -1,4 +1,15 @@
-''' Define test function for scipy package '''
+''' Define test function for scipy package
+
+Module tests for presence of nose. If present returns NoseTester,
+otherwise returns a placeholder test routine reporting lack of nose
+and inability to run tests. Typical use is in module __init__:
+
+from scipy.testing.pkgtester import Tester
+test = Tester().test
+
+See nosetester module for test implementation
+
+'''
try:
import nose
except ImportError:
More information about the Scipy-svn
mailing list