Ñò ]ÐKc@sqdZddkZddkZddklZlZd„Zed„Zdd„Z dd„Z ed„Z dS( 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(tWarningManagertWarningMessagecCs 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' (tTruetslow(tt((s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyRs cs‡fd†}|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 cs ˆ|_|S(N(t__test__(R(ttf(s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pytset_testUs ((RR((Rs>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt setastest9scs‡‡fd†}|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. cs¶ddk‰tˆƒo‡fd†‰n‡fd†‰dd„‰‡‡‡‡‡fd†}‡‡‡‡‡fd†}ˆiiˆƒo |}n|}ˆiiˆƒ|ƒS(NiÿÿÿÿcsˆƒS((((tskip_condition(s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt~scsˆS((((R (s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyR €scSs2|djo d}n d|}d|i|fS(s;Skip message with information about function being skipped.s"Test skipped due to test conditions sSkipping test: %s%sN(tNonet__name__(tfunctmsgtout((s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pytget_msg‚s   cs7ˆƒoˆiˆˆˆƒƒ‚nˆ||ŽSdS(s"Skipper for normal test functions.N(tSkipTest(targstkwargs(tfRtnoseRtskip_val(s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt skipper_funcs c?sIˆƒoˆiˆˆˆƒƒ‚n xˆ||ŽD] }|Vq6WdS(sSkipper for test generators.N(R(RRtx(RRRRR(s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt skipper_gen”s  (RtcallableR tutilt isgeneratorttoolstmake_decorator(RRRtskipper(R R(RRRRs>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pytskip_decoratorws     ((R RR ((RR s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pytskipifZs-cs\ˆdjo d‰ntˆƒo‡fd†‰n‡fd†‰‡‡fd†}|S(sò Make function raise KnownFailureTest exception if 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 ---------- fail_condition : bool or callable Flag to determine whether to mark the decorated test as a known failure (if True) or not (if False). msg : str, optional Message to give on raising a KnownFailureTest 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. s!Test skipped due to known failurecsˆƒS((((tfail_condition(s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyR ÊscsˆS((((R"(s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyR ÌscsJddk}ddkl‰‡‡‡‡fd†}|iiˆƒ|ƒS(Niÿÿÿÿ(tKnownFailureTestcs(ˆƒo ˆˆ‚nˆ||ŽSdS(N((RR(Rtfail_valR#R(s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt knownfailerÓs  (Rt noseclassesR#RR(RRR%(R$R(RR#s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pytknownfail_decoratorÎs N(R R(R"RR'((R"R$Rs>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pytknownfailureif§s    cs‡fd†}|S(s™ Filter deprecation warnings while running the test suite. This decorator can be used to filter DeprecationWarning's, to avoid printing them during the test suite run, while checking that the test actually raises a DeprecationWarning. Parameters ---------- conditional : bool or callable, optional Flag to determine whether to mark test as deprecated or not. If the condition is a callable, it is used at runtime to dynamically make the decision. Default is True. Returns ------- decorator : function The `deprecated` decorator itself. Notes ----- .. versionadded:: 1.4.0 csqddk}ddkl}‡fd†}tˆƒo ˆƒ}nˆ}|o|iiˆƒ|ƒSˆSdS(Niÿÿÿÿ(R#csªtdtƒ}|iƒ}tidƒzpˆ||Žt|ƒdjptdˆiƒ‚n|dit j o!tdˆi|dfƒ‚nWd|i ƒXdS(Ntrecordtalwaysis!No warning raised when calling %ss8First warning for %s is not a DeprecationWarning( is %s)( RRt __enter__twarningst simplefiltertlentAssertionErrorR tcategorytDeprecationWarningt__exit__(RRtctxtl(R(s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt_deprecated_impûs   (RR&R#RRR(RRR#R5tcond(t conditional(Rs>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pytdeprecate_decoratorõs   ((R7R8((R7s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyt deprecatedÜs( t__doc__R,tsystnumpy.testing.utilsRRRRRR R!R(R9(((s>/usr/lib64/python2.6/site-packages/numpy/testing/decorators.pyts   # ! M 5