Format: application/x-python-code
⬇ Download File (3.2 KB)
   1  o
   2  
   3  ��h��@sLdZddlmZmZedd��Zedd��Zedd��ZGd	d
   4  �d
   5  e�ZdS)a�Tests for IPython's test support utilities.
   6  
   7  These are decorators that allow standalone functions and docstrings to be seen
   8  as tests by unittest, replicating some of nose's functionality.  Additionally,
   9  IPython-syntax docstrings can be auto-converted to '>>>' so that ipython
  10  sessions can be copy-pasted as tests.
  11  
  12  This file can be run as a script, and it will call unittest.main().  We must
  13  check that it works with unittest as well as with nose...
  14  
  15  
  16  Notes:
  17  
  18  - Using nosetests --with-doctest --doctest-tests testfile.py
  19    will find docstrings as tests wherever they are, even in methods.  But
  20    if we use ipython syntax in the docstrings, they must be decorated with
  21    @ipdocstring.  This is OK for test-only code, but not for user-facing
  22    docstrings where we want to keep the ipython syntax.
  23  
  24  - Using nosetests --with-doctest file.py
  25    also finds doctests if the file name doesn't have 'test' in it, because it is
  26    treated like a normal module.  But if nose treats the file like a test file,
  27    then for normal classes to be doctested the extra --doctest-tests is
  28    necessary.
  29  
  30  - running this script with python (it has a __main__ section at the end) misses
  31    one docstring test, the one embedded in the Foo object method.  Since our
  32    approach relies on using decorators that create standalone TestCase
  33    instances, it can only be used for functions, not for methods of objects.
  34  Authors
  35  -------
  36  
  37  - Fernando Perez <Fernando.Perez@berkeley.edu>
  38  �)�	ipdoctest�ipdocstringcC�dS)z
  39      >>> print(1+1)
  40      2
  41      N�rrr�[c:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/testing/tests/test_ipunittest.py�	simple_dt5�rcCr)z�
  42  In [20]: print(1)
  43  1
  44  
  45  In [26]: for i in range(4):
  46     ....:     print(i)
  47     ....:     
  48     ....: 
  49  0
  50  1
  51  2
  52  3
  53  
  54  In [27]: 3+4
  55  Out[27]: 7
  56  Nrrrrr�
  57  ipdt_flush=rr	cCr)z�
  58      In [20]: print(1)
  59      1
  60  
  61      In [26]: for i in range(4):
  62         ....:     print(i)
  63         ....:     
  64         ....: 
  65      0
  66      1
  67      2
  68      3
  69  
  70      In [27]: 3+4
  71      Out[27]: 7
  72      Nrrrrr�ipdt_indented_testQrr
  73  c@s$eZdZdZedd��Zdd�ZdS)�Fooz�For methods, the normal decorator doesn't work.
  74  
  75      But rewriting the docstring with ip2py does, *but only if using nose
  76      --with-doctest*.  Do we want to have that as a dependency?
  77      cCr)z�
  78          In [20]: print(1)
  79          1
  80  
  81          In [26]: for i in range(4):
  82             ....:     print(i)
  83             ....:     
  84             ....: 
  85          0
  86          1
  87          2
  88          3
  89  
  90          In [27]: 3+4
  91          Out[27]: 7
  92          Nr��selfrrr�ipdt_methodlrzFoo.ipdt_methodcCr)z*
  93          >>> print(1+1)
  94          2
  95          Nrrrrr�normaldt_methodrzFoo.normaldt_methodN)�__name__�
  96  __module__�__qualname__�__doc__rrrrrrrres
  97  
  98  rN)	rZIPython.testing.ipunittestrrrr	r
  99  �objectrrrrr�<module>s/
 100  
 101  
 102