testing.nosetester

Module: testing.nosetester

Inheritance diagram for nipy.testing.nosetester:

Inheritance diagram of nipy.testing.nosetester

Nipy nosetester

Sets doctests to run by default

Use our own doctest plugin (based on that of numpy)

Class

NipyNoseTester

class nipy.testing.nosetester.NipyNoseTester(package=None)

Bases: nipy.fixes.numpy.testing.nosetester.NoseTester

Numpy-like testing class

  • Removes some numpy-specific excludes
  • Disables numpy’s fierce clearout of module import context for doctests
  • Run doctests by default

Methods

bench([label, verbose, extra_argv]) Run benchmarks for module using nose.
prepare_test_args([label, verbose, …]) Run tests for module using nose.
test([label, verbose, extra_argv, doctests, …]) Run tests for module using nose.
__init__(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

bench(label='fast', verbose=1, extra_argv=None)

Run benchmarks for module using nose.

Parameters:

label : {‘fast’, ‘full’, ‘’, attribute identifier}, optional

Identifies the benchmarks 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 the nosetests -A

option of ‘not slow’.

  • ‘full’ - fast (as above) and slow benchmarks as in the ‘no -A’ option to nosetests - this is the same as ‘’.
  • None or ‘’ - run all tests.

attribute_identifier - string passed directly to nosetests as ‘-A’.

verbose : int, optional

Verbosity value for benchmark outputs, in the range 1-10. Default is 1.

extra_argv : list, optional

List with any extra arguments to pass to nosetests.

Returns:

success : bool

Returns True if running the benchmarks works, False if an error occurred.

Notes

Benchmarks are like tests, but have names starting with “bench” instead of “test”, and can be found under the “benchmarks” sub-directory of the module.

Each NumPy module exposes bench in its namespace to run all benchmarks for it.

Examples

>>> success = np.lib.bench() 
Running benchmarks for numpy.lib
...
using 562341 items:
unique:
0.11
unique1d:
0.11
ratio: 1.0
nUnique: 56230 == 56230
...
OK
>>> success 
True
excludes = []
prepare_test_args(label='fast', verbose=1, extra_argv=None, doctests=False, coverage=False)

Run tests for module using nose.

This method does the heavy lifting for the test method. It takes all the same arguments, for details see test.

See also

test

test(label='fast', verbose=1, extra_argv=None, doctests=True, coverage=False)

Run tests for module using nose.

As for numpy tester, except enable tests by default.

Parameters:

label : {‘fast’, ‘full’, ‘’, attribute identifier}, optional

Identifies the tests to run. This can be a string to pass to directly the nosetests executable with the ‘-A’ option (an attribute identifier), or one of several special values. Special values are:

  • ‘fast’ - the default - which corresponds to the nosetests -A option of ‘not slow’.
  • ‘full’ - fast (as above) and slow tests as in the ‘no -A’ option to nosetests - this is the same as ‘’.
  • None or ‘’ - run all tests.

verbose : int, optional

Verbosity value for test outputs, in the range 1-10. Default is 1.

extra_argv : list, optional

List with any extra arguments to pass to nosetests.

doctests : bool, optional

If True, run doctests in module. Default is True.

coverage : bool, optional

If True, report coverage of nipy code. Default is False. (This requires the `coverage module:

Returns:

result : object

Returns the result of running the tests as a nose.result.TextTestResult object.

Notes

Each nipy module should expose test in its namespace to run all tests for it. For example, to run all tests for nipy.algorithms:

>>> import nipy.algorithms
>>> nipy.algorithms.test() 

Functions

nipy.testing.nosetester.fpw_opt_str()

Return first-package-wins option string for this version of nose

Versions of nose prior to 1.1.0 needed =True for first-package-wins, versions after won’t accept it.

changeset: 816:c344a4552d76 http://code.google.com/p/python-nose/issues/detail?id=293

Returns:

fpw_str : str

Either ‘–first-package-wins’ or ‘–first-package-wins=True’ depending on the nose version we are running.

nipy.testing.nosetester.prepare_imports()

Prepare any imports for testing run

At the moment, we prepare matplotlib by trying to make it use a backend that does not need a display