mvpa2.testing.toolsΒΆ

A Collection of tools found useful in unittests.

Primarily the ones from nose.tools

Functions

assert_almost_equal(actual, desired[, ...]) Raise an assertion if two items are not equal up to desired precision.
assert_approx_equal(actual, desired[, ...]) Raise an assertion if two items are not equal up to significant digits.
assert_array_almost_equal(x, y[, decimal, ...]) Raise an assertion if two objects are not equal up to desired precision.
assert_array_equal(x, y[, err_msg, verbose]) Raise an assertion if two array_like objects are not equal.
assert_array_lequal(x, y)
assert_array_less(x, y[, err_msg, verbose]) Raise an assertion if two array_like objects are not ordered by less than.
assert_objectarray_equal(x, y[, xorig, ...]) Wrapper around assert_array_equal to compare object arrays See http://projects.scipy.org/numpy/ticket/2117 for the original report on oddity of dtype object arrays comparisons :Parameters: strict: bool : Assure also that dtypes are the same.
assert_string_equal(actual, desired) Test if two strings are equal.
eq_(a, b[, msg]) Shorthand for ‘assert a == b, “%r != %r” % (a, b)
istest(func) Decorator to mark a function or method as a test
labile([niter, nfailures]) Decorator for labile tests – runs multiple times Let’s reduce probability of random failures but re-running the test multiple times allowing to fail few in a row.
make_decorator(func) Wraps a test decorator so as to properly replicate metadata of the decorated function, including nose’s additional stuff (namely, setup and teardown).
nodebug([entries]) Decorator to temporarily turn off some debug targets :Parameters: entries : None or list of string, optional If None, all debug entries get turned off.
nottest(func) Decorator to mark a function or method as not a test
ok_(expr[, msg]) Shorthand for assert.
raises(*exceptions) Test must raise one of expected exceptions to pass.
reseed_rng() Decorator to assure the use of MVPA_SEED while running the test It resets random number generators (both python and numpy) to the initial value of the seed value which was set while importing mvpa, which could be controlled through configuration/environment.
skip_if_no_external(dep[, ver_dep, ...]) Raise SkipTest if external is missing :Parameters: dep : string Name of the external ver_dep : string, optional If for version checking use some different key, e.g.
timed(limit) Test must finish within specified time limit to pass.
with_setup([setup, teardown]) Decorator to add setup and/or teardown methods to a test function:: @with_setup(setup, teardown) def test_something(): ” ...
with_tempfile(*targs, **tkwargs) Decorator function to provide a temporary file name and remove it at the end.

Exceptions

NeuroDebian

NITRC-listed