Current File : //usr/lib64/python2.7/site-packages/numpy/testing/decorators.pyo
�
E�`Qc@sqdZddlZddlZddlmZmZd�Zed�Zdd�Z
dd�Zed�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.7/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.7/site-packages/numpy/testing/decorators.pytset_testUs	((RR((Rs>/usr/lib64/python2.7/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�ddl�t��r*�fd��n�fd��dd�������fd�}�����fd�}�jj��r�|}n|}�jj��|�S(Ni����cs��S(N(((tskip_condition(s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pyt<lambda>~scs�S(N(((R	(s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pyR
�scSs0|dkrd}n
d|}d|j|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.7/site-packages/numpy/testing/decorators.pytget_msg�s	
cs5��r$�j������n
�||�SdS(s"Skipper for normal test functions.N(tSkipTest(targstkwargs(tfRRtnosetskip_val(s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pytskipper_func�s	c?sG��r$�j������nx�||�D]}|Vq4WdS(sSkipper for test generators.N(R(RRtx(RRRRR(s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pytskipper_gen�s	(RtcallableRtutiltisgeneratorttoolstmake_decorator(RRRtskipper(RR	(RRRRs>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pytskip_decoratorws		((R	RR ((RR	s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pytskipifZs-csX�dkrd�nt��r3�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(N(((tfail_condition(s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pyR
�scs�S(N(((R"(s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pyR
�scsJddl}ddlm�����fd�}|jj��|�S(Ni����(tKnownFailureTestcs)��r����n
�||�SdS(N((RR(R#Rtfail_valR(s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pytknownfailer�s	(RtnoseclassesR#RR(RRR%(R$R(R#Rs>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pytknownfail_decorator�sN(RR(R"RR'((R"R$Rs>/usr/lib64/python2.7/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

    csmddl}ddlm}�fd�}t��rC��}n�}|re|jj��|�S�SdS(Ni����(R#cs�tdt�}|j�}tjd�zl�||�t|�dks`td�j��n|djt	k	r�td�j|df��nWd|j
�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.7/site-packages/numpy/testing/decorators.pyt_deprecated_imp�s

(RR&R#RRR(RRR#R5tcond(tconditional(Rs>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pytdeprecate_decorator�s((R7R8((R7s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pyt
deprecated�s(
t__doc__R,tsystnumpy.testing.utilsRRRRRRR!R(R9(((s>/usr/lib64/python2.7/site-packages/numpy/testing/decorators.pyt<module>s	#!M5