Format: application/x-python-code
⬇ Download File (4.3 KB)
   1  o
   2  
   3  ��h��@s�dZddlZddlZddlmZddlmZddlm	Z	dd�Z
   4  ejdd	��Ze�
   5  �d
   6  d��Ze�
   7  d�d
   8  d��Zed dd��Zdd�Zdd�ZGdd�de�Zdd�Zejdd��Zejdd��Zejdd��ZdS)!z4Tests for the decorators we've created for IPython.
   9  �N)�
  10  decorators)�skip_doctest)�dedentcCsJt�|�r|}n
  11  t�|�r|j}ntd��t�|j�\}}}||||jfS)a�Get the names and default values of a function's arguments.
  12  
  13      A tuple of four things is returned: (args, varargs, varkw, defaults).
  14      'args' is a list of the argument names (it may contain nested lists).
  15      'varargs' and 'varkw' are the names of the * and ** arguments or None.
  16      'defaults' is an n-tuple of the default values of the last n arguments.
  17  
  18      Modified version of inspect.getargspec from the Python Standard
  19      Library.zarg is not a Python function)�inspect�
  20  isfunction�ismethod�__func__�	TypeError�getargs�__code__�__defaults__)�objZfunc_obj�args�varargs�varkw�r�[c:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/testing/tests/test_decorators.py�
  21  getargspecs
  22  
  23  rcC�dS)zA trivial testNrrrrr�trivial*srcC�dddS)z6A deliberately broken test - we want to skip this one.�rNrrrrr�test_deliberately_broken0�rzTesting the skip decoratorcCr)z<Another deliberately broken test - we want to skip this one.rrNrrrrr�test_deliberately_broken25rrrcKs"td|�td|�td|�dS)�AA function whose doctest we need to skip.
  24  
  25      >>> 1+1
  26      3
  27      zx:zy:zk:N)�print)�x�y�krrr�doctest_bad=s
  28  
  29  r cCr)zvCheck that we can still call the decorated functions.
  30      
  31      >>> doctest_bad(3,y=4)
  32      x: 3
  33      y: 4
  34      k: {}
  35      Nrrrrr�call_doctest_badIsr!cCs&d}tj}t|�t|�ksJd��dS)z>Doctest-skipping decorator should preserve the docstring.
  36      rz"doctest_bad docstrings don't matchN)r �__doc__r)�check�valrrr�test_skip_dt_decoratorTsr%c@s0eZdZdZedd��Zedd��Zdd�ZdS)	�FooClassz.FooClass
  37  
  38      Example:
  39  
  40      >>> 1+1
  41      2
  42      cCstd�||_dS)zUMake a FooClass.
  43  
  44          Example:
  45  
  46          >>> f = FooClass(3)
  47          junk
  48          zMaking a FooClass.N)rr)�selfrrrr�__init__ns	
  49  zFooClass.__init__cCsd|S)zpExample:
  50  
  51          >>> ff = FooClass(3)
  52          >>> ff.bar(0)
  53          boom!
  54          >>> 1/0
  55          bam!
  56          rr�r'rrrr�barzs
  57  zFooClass.barcCs
  58  |j|kS)zoExample:
  59  
  60          >>> ff2 = FooClass(3)
  61          Making a FooClass.
  62          >>> ff2.baz(3)
  63          True
  64          )rr)rrr�baz�s
  65  zFooClass.bazN)�__name__�
  66  __module__�__qualname__r"rr(r*r+rrrrr&es
  67  
  68  r&cCs2ddgdddf}tt�}||ksJd|f��dS)zCDoctest-skipping decorator should preserve function signature.
  69      rrNr�rz2Incorrectly reconstructed args for doctest_bad: %s)rr )ZdtargsZdtargsrrrr�test_skip_dt_decorator2�s
  70  
  71  �r0cCstj�d�dusJd��dS)N�linuxFzThis test can't run under linux)�sys�platform�
  72  startswithrrrr�
  73  test_linux�sr5cC�tjdks	Jd��dS)N�win32z!This test can't run under windows�r2r3rrrr�
  74  test_win32��r9cCr6)N�darwinzThis test can't run under osxr8rrrr�test_osx�r:r<r/)r"rr2ZIPython.testingr�decZIPython.testing.skipdoctestrZIPython.utils.textrrZas_unittestr�skiprrr r!r%�objectr&r0Z
  75  skip_linuxr5Z
  76  skip_win32r9Zskip_osxr<rrrr�<module>s2
  77  
  78  
  79  ,
  80  
  81