Ñò
]ÐKc @ sq d Z d d k Z d d k Z d d k l Z l Z d „ Z e d „ Z d d „ Z
d d „ Z e d „ Z d S( sÅ
Decorators for labeling and modifying behavior of test objects.
Decorators that merely return a modified version of the original
function object are straightforward. Decorators that return a new
function object need to use
::
nose.tools.make_decorator(original_function)(decorator)
in returning the decorator, in order to preserve meta-data such as
function name, setup and teardown functions and so on - see
``nose.tools`` for more information.
iÿÿÿÿN( t WarningManagert WarningMessagec C s
t | _ | S( sà
Label a test as 'slow'.
The exact definition of a slow test is obviously both subjective and
hardware-dependent, but in general any individual test that requires more
than a second or two should be labeled as slow (the whole suite consits of
thousands of tests, so even a second is significant).
Parameters
----------
t : callable
The test to label as slow.
Returns
-------
t : callable
The decorated test `t`.
Examples
--------
The `numpy.testing` module includes ``import decorators as dec``.
A test can be decorated as slow like this::
from numpy.testing import *
@dec.slow
def test_big(self):
print 'Big, slow test'
( t Truet slow( t t( ( s> /usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyR s c s ‡ f d † } | S( s¡
Signals to nose that this function is or is not a test.
Parameters
----------
tf : bool
If True, specifies that the decorated callable is a test.
If False, specifies that the decorated callable is not a test.
Default is True.
Notes
-----
This decorator can't use the nose namespace, because it can be
called from a non-test module. See also ``istest`` and ``nottest`` in
``nose.tools``.
Examples
--------
`setastest` can be used in the following way::
from numpy.testing.decorators import setastest
@setastest(False)
def func_with_test_in_name(arg1, arg2):
pass
c s
ˆ | _ | S( N( t __test__( R ( t tf( s> /usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt set_testU s ( ( R R ( ( R s> /usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt setastest9 s c s ‡ ‡ f d † } | S( s¤
Make function raise SkipTest exception if a given condition is true.
If the condition is a callable, it is used at runtime to dynamically
make the decision. This is useful for tests that may require costly
imports, to delay the cost until the test suite is actually executed.
Parameters
----------
skip_condition : bool or callable
Flag to determine whether to skip the decorated test.
msg : str, optional
Message to give on raising a SkipTest exception. Default is None.
Returns
-------
decorator : function
Decorator which, when applied to a function, causes SkipTest
to be raised when `skip_condition` is True, and the function
to be called normally otherwise.
Notes
-----
The decorator itself is decorated with the ``nose.tools.make_decorator``
function in order to transmit function name, and various other metadata.
c s¶ d d k ‰ t ˆ ƒ o ‡ f d † ‰ n ‡ f d † ‰ d d „ ‰ ‡ ‡ ‡ ‡ ‡ f d † } ‡ ‡ ‡ ‡ ‡ f d † } ˆ i i ˆ ƒ o
| } n | } ˆ i i ˆ ƒ | ƒ S( Niÿÿÿÿc s ˆ ƒ S( ( ( ( t skip_condition( s> /usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt