B .set_testr )r r r )r r setastest:s rcsfdd}|S)a 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. csddl}ttjr"fddn fddd ddfdd}fd d }|jrn|}n|}|j|S) NrcsS)Nr r )skip_conditionr r z0skipif..skip_decorator..csS)Nr r )rr r rrcSs |dkrd}n|}d|j|fS)z;Skip message with information about function being skipped.Nz"Test skipped due to test conditionzSkipping test: %s: %s)__name__)funcmsgoutr r r get_msgsz/skipif..skip_decorator..get_msgcs$rtn ||SdS)z"Skipper for normal test functions.N)r)argskwargs)frrskip_valr r skipper_funcsz4skipif..skip_decorator..skipper_funcc?s4rtnx||D] }|Vq"WdS)zSkipper for test generators.N)r)rrx)rrrrr r skipper_gensz3skipif..skip_decorator..skipper_gen)N)nose isinstance collectionsCallableutilZ isgeneratortoolsmake_decorator)rrrrZskipper)rr)rrrr skip_decoratorxs    zskipif..skip_decoratorr )rrr%r )rrr skipif[s-r&csDdkr dttjr&fddn fddfdd}|S)a  Make function raise KnownFailureException 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 KnownFailureException exception. Default is None. Returns ------- decorator : function Decorator, which, when applied to a function, causes KnownFailureException to be raised when `fail_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. Nz!Test skipped due to known failurecsS)Nr r )fail_conditionr r rrz knownfailureif..csS)Nr r )r'r r rrcs6ddl}ddlmfdd}|j|S)Nrr)KnownFailureExceptioncsrn ||SdS)Nr )rr)r(rfail_valrr r knownfailers z@knownfailureif..knownfail_decorator..knownfailer)rZ noseclassesr(r#r$)rrr*)r)r)r(rr knownfail_decorators z+knownfailureif..knownfail_decorator)rr r!)r'rr+r )r'r)rr knownfailureifs   r,csfdd}|S)a 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 csHddl}fdd}ttjr(}n}|r@|j|SSdS)Nrc s"tt||WdQRXdS)N)rDeprecationWarning)rr)rr r _deprecated_imps z@deprecated..deprecate_decorator.._deprecated_imp)rrr r!r#r$)rrr.Zcond) conditional)rr deprecate_decorators  z'deprecated..deprecate_decoratorr )r/r0r )r/r deprecateds r1)T)N)N)T)__doc__Z __future__rrrr Zutilsrrrrr&r,r1r r r r s# ! M 6