o
    û›h¦  ã                   @   sÔ   d Z ddlZddlZddlmZ ddlmZ ddlm	Z	 dd„ Z
ejdd	„ ƒZe ¡ d
d„ ƒZe d¡dd„ ƒZed dd„ƒZdd„ Zdd„ ZG dd„ deƒZdd„ Zejdd„ ƒZejdd„ ƒZejdd„ ƒZdS )!z4Tests for the decorators we've created for IPython.
é    N)Ú
decorators)Úskip_doctest)Údedentc                 C   sJ   t  | ¡r| }nt  | ¡r| j}ntdƒ‚t  |j¡\}}}||||jfS )a¹  Get the names and default values of a function's arguments.

    A tuple of four things is returned: (args, varargs, varkw, defaults).
    'args' is a list of the argument names (it may contain nested lists).
    'varargs' and 'varkw' are the names of the * and ** arguments or None.
    'defaults' is an n-tuple of the default values of the last n arguments.

    Modified version of inspect.getargspec from the Python Standard
    Library.zarg is not a Python function)ÚinspectÚ
isfunctionÚismethodÚ__func__Ú	TypeErrorÚgetargsÚ__code__Ú__defaults__)ÚobjZfunc_objÚargsÚvarargsÚvarkw© r   ú[c:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/testing/tests/test_decorators.pyÚ
getargspec   s   

r   c                   C   ó   dS )zA trivial testNr   r   r   r   r   Útrivial*   s   r   c                   C   ó   dd  dS )z6A deliberately broken test - we want to skip this one.é   r   Nr   r   r   r   r   Útest_deliberately_broken0   ó   r   zTesting the skip decoratorc                   C   r   )z<Another deliberately broken test - we want to skip this one.r   r   Nr   r   r   r   r   Útest_deliberately_broken25   r   r   r   c                 K   s"   t d| ƒ t d|ƒ t d|ƒ dS )úAA function whose doctest we need to skip.

    >>> 1+1
    3
    zx:zy:zk:N)Úprint)ÚxÚyÚkr   r   r   Údoctest_bad=   s   

r    c                   C   r   )zvCheck that we can still call the decorated functions.
    
    >>> doctest_bad(3,y=4)
    x: 3
    y: 4
    k: {}
    Nr   r   r   r   r   Úcall_doctest_badI   s   r!   c                  C   s&   d} t j}t| ƒt|ƒksJ dƒ‚dS )z>Doctest-skipping decorator should preserve the docstring.
    r   z"doctest_bad docstrings don't matchN)r    Ú__doc__r   )ÚcheckÚvalr   r   r   Útest_skip_dt_decoratorT   s   r%   c                   @   s0   e Zd ZdZedd„ ƒZedd„ ƒZdd„ ZdS )	ÚFooClassz.FooClass

    Example:

    >>> 1+1
    2
    c                 C   s   t dƒ || _dS )zUMake a FooClass.

        Example:

        >>> f = FooClass(3)
        junk
        zMaking a FooClass.N)r   r   )Úselfr   r   r   r   Ú__init__n   s   	
zFooClass.__init__c                 C   s   d| S )zpExample:

        >>> ff = FooClass(3)
        >>> ff.bar(0)
        boom!
        >>> 1/0
        bam!
        r   r   ©r'   r   r   r   r   Úbarz   s   
zFooClass.barc                 C   s
   | j |kS )zoExample:

        >>> ff2 = FooClass(3)
        Making a FooClass.
        >>> ff2.baz(3)
        True
        )r   r)   r   r   r   Úbaz†   s   
zFooClass.bazN)Ú__name__Ú
__module__Ú__qualname__r"   r   r(   r*   r+   r   r   r   r   r&   e   s    

r&   c                  C   s2   ddgdddf} t tƒ}|| ksJ d|f ƒ‚dS )zCDoctest-skipping decorator should preserve function signature.
    r   r   Nr   ©r   z2Incorrectly reconstructed args for doctest_bad: %s)r   r    )ZdtargsZdtargsrr   r   r   Útest_skip_dt_decorator2‘   s
   
ÿr0   c                   C   s   t j d¡du sJ dƒ‚d S )NÚlinuxFzThis test can't run under linux)ÚsysÚplatformÚ
startswithr   r   r   r   Ú
test_linuxœ   s   r5   c                   C   ó   t jdks	J dƒ‚d S )NÚwin32z!This test can't run under windows©r2   r3   r   r   r   r   Ú
test_win32¡   ó   r9   c                   C   r6   )NÚdarwinzThis test can't run under osxr8   r   r   r   r   Útest_osx¦   r:   r<   r/   )r"   r   r2   ZIPython.testingr   ÚdecZIPython.testing.skipdoctestr   ZIPython.utils.textr   r   Zas_unittestr   Úskipr   r   r    r!   r%   Úobjectr&   r0   Z
skip_linuxr5   Z
skip_win32r9   Zskip_osxr<   r   r   r   r   Ú<module>   s2    


,

