Table Of Contents

Previous topic

neurospin.utils.mask

Next topic

neurospin.utils.roi

This Page

neurospin.utils.nosetester

Module: neurospin.utils.nosetester

Inheritance diagram for nipy.neurospin.utils.nosetester:

Nose test running

Implements test and bench functions for modules.

Class

NoseTester

class nipy.neurospin.utils.nosetester.NoseTester(package=None)

Bases: object

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.

Typical call is from module __init__, and corresponds to this:

test = NoseTester().test

This class is made available as numpy.testing.Tester:

from scipy.testing import Tester test = Tester().test
__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 identifer}

Identifies benchmark 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’.

‘full’ - fast (as above) and slow benchmark as in

no -A option to nosetests - same as ‘’

None or ‘’ - run all benchmarks attribute_identifier - string passed directly to

nosetests as ‘-A’

verbose : integer

verbosity value for test outputs, 1-10

extra_argv : list

List with any extra args to pass to nosetests

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

Run tests for module using nose

Parameters:

label : {‘fast’, ‘full’, ‘’, attribute identifer}

Identifies test 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’.

‘full’ - fast (as above) and slow test as in

no -A option to nosetests - same as ‘’

None or ‘’ - run all tests attribute_identifier - string passed directly to

nosetests as ‘-A’

verbose : integer

verbosity value for test outputs, 1-10

extra_argv : list

List with any extra args to pass to nosetests

doctests : boolean

If True, run doctests in module, default False

coverage : boolean

If True, report coverage of NumPy code, default False (Requires the coverage module:

http://nedbatchelder.com/code/modules/coverage.html)

Functions

nipy.neurospin.utils.nosetester.import_nose()
Import nose only when needed.
nipy.neurospin.utils.nosetester.run_module_suite(file_to_run=None)
nipy.neurospin.utils.nosetester.skipif(skip_condition, msg=None)

Make function raise SkipTest exception if skip_condition is true

Parameters:

skip_condition : bool

Flag to determine whether to skip test (True) or not (False)

msg : string

Message to give on raising a SkipTest exception

Returns:

decorator : function

Decorator, which, when applied to a function, causes SkipTest to be raised when the skip_condition was True, and the function to be called normally otherwise.

Notes

You will see from the code that we had to further decorate the decorator with the nose.tools.make_decorator function in order to transmit function name, and various other metadata.