Format: application/x-python-code
1 o
2
3 ��h� � @ sL d Z ddlmZmZ edd� �Zedd� �Zedd� �ZG d 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�ipdocstringc C � dS )z
39 >>> print(1+1)
40 2
41 N� r r r �[c:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/testing/tests/test_ipunittest.py� simple_dt5 � r c C r )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 Nr r r r r �
57 ipdt_flush= r r c C r )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 Nr r r r r �ipdt_indented_testQ r r
73 c @ s$ e Zd ZdZedd� �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 c C r )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 ��selfr r r �ipdt_methodl r zFoo.ipdt_methodc C r )z*
93 >>> print(1+1)
94 2
95 Nr r r r r �normaldt_method r zFoo.normaldt_methodN)�__name__�
96 __module__�__qualname__�__doc__r r r r r r r r e s
97
98 r N) r ZIPython.testing.ipunittestr r r r r
99 �objectr r r r r �<module> s /
100
101
102