diff options
author | Jarrod Millman <millman@berkeley.edu> | 2008-08-08 04:33:45 +0000 |
---|---|---|
committer | Jarrod Millman <millman@berkeley.edu> | 2008-08-08 04:33:45 +0000 |
commit | 70ed0f238156680efba9b4028810f3aed486357b (patch) | |
tree | e5e0f42e586156ed74128cff0fe84404398b918b /numpy/testing | |
parent | 0da812e06828be6749b1840b48c4f100dc3dfd68 (diff) | |
download | numpy-70ed0f238156680efba9b4028810f3aed486357b.tar.gz |
ran reindent
Diffstat (limited to 'numpy/testing')
-rw-r--r-- | numpy/testing/__init__.py | 2 | ||||
-rw-r--r-- | numpy/testing/decorators.py | 8 | ||||
-rw-r--r-- | numpy/testing/noseclasses.py | 26 | ||||
-rw-r--r-- | numpy/testing/nosetester.py | 33 | ||||
-rw-r--r-- | numpy/testing/numpytest.py | 2 | ||||
-rw-r--r-- | numpy/testing/parametric.py | 2 | ||||
-rw-r--r-- | numpy/testing/utils.py | 2 |
7 files changed, 37 insertions, 38 deletions
diff --git a/numpy/testing/__init__.py b/numpy/testing/__init__.py index 06e49cf2a..53941fd76 100644 --- a/numpy/testing/__init__.py +++ b/numpy/testing/__init__.py @@ -10,7 +10,7 @@ from unittest import TestCase import decorators as dec from utils import * -from parametric import ParametricTestCase +from parametric import ParametricTestCase from numpytest import * from nosetester import NoseTester as Tester from nosetester import run_module_suite diff --git a/numpy/testing/decorators.py b/numpy/testing/decorators.py index dd9783e2f..77871d339 100644 --- a/numpy/testing/decorators.py +++ b/numpy/testing/decorators.py @@ -72,8 +72,8 @@ def skipif(skip_condition, msg=None): if msg is None: msg = 'Test skipped due to test condition' def skip_decorator(f): - # Local import to avoid a hard nose dependency and only incur the - # import time overhead at actual test-time. + # Local import to avoid a hard nose dependency and only incur the + # import time overhead at actual test-time. import nose def skipper(*args, **kwargs): if skip_condition: @@ -86,8 +86,8 @@ def skipif(skip_condition, msg=None): def skipknownfailure(f): ''' Decorator to raise SkipTest for test known to fail ''' - # Local import to avoid a hard nose dependency and only incur the - # import time overhead at actual test-time. + # Local import to avoid a hard nose dependency and only incur the + # import time overhead at actual test-time. import nose def skipper(*args, **kwargs): raise nose.SkipTest, 'This test is known to fail' diff --git a/numpy/testing/noseclasses.py b/numpy/testing/noseclasses.py index c2fb85e0b..68b9dff8f 100644 --- a/numpy/testing/noseclasses.py +++ b/numpy/testing/noseclasses.py @@ -134,12 +134,12 @@ class numpyDocTestCase(npd.DocTestCase): return name -# second-chance checker; if the default comparison doesn't +# second-chance checker; if the default comparison doesn't # pass, then see if the expected output string contains flags that # tell us to ignore the output class numpyOutputChecker(doctest.OutputChecker): def check_output(self, want, got, optionflags): - ret = doctest.OutputChecker.check_output(self, want, got, + ret = doctest.OutputChecker.check_output(self, want, got, optionflags) if not ret: if "#random" in want: @@ -148,7 +148,7 @@ class numpyOutputChecker(doctest.OutputChecker): return ret -# Subclass nose.plugins.doctests.DocTestCase to work around a bug in +# Subclass nose.plugins.doctests.DocTestCase to work around a bug in # its constructor that blocks non-default arguments from being passed # down into doctest.DocTestCase class numpyDocTestCase(npd.DocTestCase): @@ -156,13 +156,13 @@ class numpyDocTestCase(npd.DocTestCase): checker=None, obj=None, result_var='_'): self._result_var = result_var self._nose_obj = obj - doctest.DocTestCase.__init__(self, test, + doctest.DocTestCase.__init__(self, test, optionflags=optionflags, - setUp=setUp, tearDown=tearDown, + setUp=setUp, tearDown=tearDown, checker=checker) -print_state = numpy.get_printoptions() +print_state = numpy.get_printoptions() class numpyDoctest(npd.Doctest): name = 'numpydoctest' # call nosetests with --with-numpydoctest @@ -188,7 +188,7 @@ class numpyDoctest(npd.Doctest): try: tests = self.finder.find(module) except AttributeError: - # nose allows module.__test__ = False; doctest does not and + # nose allows module.__test__ = False; doctest does not and # throws AttributeError return if not tests: @@ -205,31 +205,31 @@ class numpyDoctest(npd.Doctest): # Each doctest should execute in an environment equivalent to # starting Python and executing "import numpy as np", and, - # for SciPy packages, an additional import of the local + # for SciPy packages, an additional import of the local # package (so that scipy.linalg.basic.py's doctests have an # implicit "from scipy import linalg" as well. # # Note: __file__ allows the doctest in NoseTester to run # without producing an error test.globs = {'__builtins__':__builtins__, - '__file__':'__main__', - '__name__':'__main__', + '__file__':'__main__', + '__name__':'__main__', 'np':numpy} - + # add appropriate scipy import for SciPy tests if 'scipy' in pkg_name: p = pkg_name.split('.') p1 = '.'.join(p[:-1]) p2 = p[-1] test.globs[p2] = __import__(pkg_name, test.globs, {}, [p2]) - + print 'additional import for %s: from %s import %s' % (test.filename, p1, p2) print ' (%s): %r' % (pkg_name, test.globs[p2]) # always use whitespace and ellipsis options optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS - yield numpyDocTestCase(test, + yield numpyDocTestCase(test, optionflags=optionflags, checker=numpyOutputChecker()) diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index 3465fd3ef..ed46681e1 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -81,7 +81,7 @@ def _docmethod(meth, testtype): extra_argv : list List with any extra args to pass to nosetests''' \ % {'testtype': testtype} - + meth.__doc__ = meth.__doc__ % {'test_header':test_header} @@ -123,7 +123,7 @@ class NoseTester(object): package = os.path.dirname(package.__file__) self.package_path = package - # find the package name under test; this name is used to limit coverage + # find the package name under test; this name is used to limit coverage # reporting (if enabled) self.package_name = get_package_name(package) @@ -144,8 +144,8 @@ class NoseTester(object): argv += extra_argv return argv - - def test(self, label='fast', verbose=1, extra_argv=None, doctests=False, + + def test(self, label='fast', verbose=1, extra_argv=None, doctests=False, coverage=False, **kwargs): ''' Run tests for module using nose @@ -154,7 +154,7 @@ class NoseTester(object): If True, run doctests in module, default False coverage : boolean If True, report coverage of NumPy code, default False - (Requires the coverage module: + (Requires the coverage module: http://nedbatchelder.com/code/modules/coverage.html) ''' @@ -165,15 +165,15 @@ class NoseTester(object): ua = ', '.join(unexpected_args) raise TypeError("test() got unexpected arguments: %s" % ua) - # issue a deprecation warning if any of the pre-1.2 arguments to + # issue a deprecation warning if any of the pre-1.2 arguments to # test are given if old_args.intersection(kwargs.keys()): warnings.warn("This method's signature will change in the next " \ "release; the level, verbosity, all, sys_argv, " \ "and testcase_pattern keyword arguments will be " \ - "removed. Please update your code.", + "removed. Please update your code.", DeprecationWarning, stacklevel=2) - + # Use old arguments if given (where it makes sense) # For the moment, level and sys_argv are ignored @@ -191,7 +191,7 @@ class NoseTester(object): label = '' doctests = True - # if doctests is in the extra args, remove it and set the doctest + # if doctests is in the extra args, remove it and set the doctest # flag so the NumPy doctester is used instead if extra_argv and '--with-doctest' in extra_argv: extra_argv.remove('--with-doctest') @@ -222,23 +222,23 @@ class NoseTester(object): print "NumPy version %s" % numpy.__version__ npdir = os.path.dirname(numpy.__file__) print "NumPy is installed in %s" % npdir - + if 'scipy' in self.package_name: import scipy print "SciPy version %s" % scipy.__version__ spdir = os.path.dirname(scipy.__file__) print "SciPy is installed in %s" % spdir - + pyversion = sys.version.replace('\n','') print "Python version %s" % pyversion print "nose version %d.%d.%d" % nose.__versioninfo__ - # Because nose currently discards the test result object, but we need - # to return it to the user, override TestProgram.runTests to retain + # Because nose currently discards the test result object, but we need + # to return it to the user, override TestProgram.runTests to retain # the result class NumpyTestProgram(nose.core.TestProgram): def runTests(self): - """Run Tests. Returns true on success, false on failure, and + """Run Tests. Returns true on success, false on failure, and sets self.success to the same value. """ if self.testRunner is None: @@ -257,7 +257,7 @@ class NoseTester(object): doctest.master = None # construct list of plugins, omitting the existing doctest plugin - import nose.plugins.builtin + import nose.plugins.builtin from noseclasses import numpyDoctest plugins = [numpyDoctest()] for p in nose.plugins.builtin.plugins: @@ -307,10 +307,9 @@ def check_whitespace_enabled(): ''' # whitespace after the 3 >>> 1+2 - 3 + 3 # whitespace before the 7 >>> 3+4 7 ''' - diff --git a/numpy/testing/numpytest.py b/numpy/testing/numpytest.py index 06229630a..c08215383 100644 --- a/numpy/testing/numpytest.py +++ b/numpy/testing/numpytest.py @@ -623,7 +623,7 @@ class NumpyTest: """ Run Numpy module test suite with level and verbosity taken from sys.argv. Requires optparse module. """ - + # delayed import of shlex to reduce startup time import shlex diff --git a/numpy/testing/parametric.py b/numpy/testing/parametric.py index 3727d3ef2..7ff68f260 100644 --- a/numpy/testing/parametric.py +++ b/numpy/testing/parametric.py @@ -189,7 +189,7 @@ class _ParametricTestCase(unittest.TestCase): else: unittest.TestCase.run(self,result) -# The underscore was added to the class name to keep nose from trying +# The underscore was added to the class name to keep nose from trying # to run the test class (nose ignores class names that begin with an # underscore by default). ParametricTestCase = _ParametricTestCase diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index af22e68ac..f28a6dd68 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -10,7 +10,7 @@ from nosetester import import_nose __all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal', 'assert_array_equal', 'assert_array_less', 'assert_string_equal', - 'assert_array_almost_equal', 'assert_raises', 'build_err_msg', + 'assert_array_almost_equal', 'assert_raises', 'build_err_msg', 'decorate_methods', 'jiffies', 'memusage', 'print_assert_equal', 'raises', 'rand', 'rundocs', 'runstring', 'verbose'] |