##// END OF EJS Templates
Various fixes for tests in IPython.testing.
Thomas Kluyver -
Show More
@@ -3,6 +3,7 b''
3 This file just contains doctests both using plain python and IPython prompts.
3 This file just contains doctests both using plain python and IPython prompts.
4 All tests should be loaded by nose.
4 All tests should be loaded by nose.
5 """
5 """
6 from IPython.utils.py3compat import doctest_refactor_print
6
7
7 def pyfunc():
8 def pyfunc():
8 """Some pure python tests...
9 """Some pure python tests...
@@ -23,7 +24,7 b' def pyfunc():'
23 """
24 """
24 return 'pyfunc'
25 return 'pyfunc'
25
26
26
27 @doctest_refactor_print
27 def ipfunc():
28 def ipfunc():
28 """Some ipython tests...
29 """Some ipython tests...
29
30
@@ -127,7 +128,7 b' def random_all():'
127 """
128 """
128 pass
129 pass
129
130
130
131 @doctest_refactor_print
131 def iprand():
132 def iprand():
132 """Some ipython tests with random output.
133 """Some ipython tests with random output.
133
134
@@ -142,7 +143,7 b' def iprand():'
142 """
143 """
143 return 'iprand'
144 return 'iprand'
144
145
145
146 @doctest_refactor_print
146 def iprand_all():
147 def iprand_all():
147 """Some ipython tests with fully random output.
148 """Some ipython tests with fully random output.
148
149
@@ -160,3 +161,4 b' def iprand_all():'
160 return 'iprand_all'
161 return 'iprand_all'
161
162
162
163
164
@@ -6,7 +6,9 b' a doctest) and which have no test functionality of their own, should be called'
6 empty function call is counted as a test, which just inflates tests numbers
6 empty function call is counted as a test, which just inflates tests numbers
7 artificially).
7 artificially).
8 """
8 """
9 from IPython.utils.py3compat import doctest_refactor_print
9
10
11 @doctest_refactor_print
10 def doctest_simple():
12 def doctest_simple():
11 """ipdoctest must handle simple inputs
13 """ipdoctest must handle simple inputs
12
14
@@ -17,17 +19,20 b' def doctest_simple():'
17 1
19 1
18 """
20 """
19
21
20
22 @doctest_refactor_print
21 def doctest_multiline1():
23 def doctest_multiline1():
22 """The ipdoctest machinery must handle multiline examples gracefully.
24 """The ipdoctest machinery must handle multiline examples gracefully.
23
25
24 In [2]: for i in range(10):
26 In [2]: for i in range(4):
25 ...: print i,
27 ...: print i
26 ...:
28 ...:
27 0 1 2 3 4 5 6 7 8 9
29 0
30 1
31 2
32 3
28 """
33 """
29
34
30
35 @doctest_refactor_print
31 def doctest_multiline2():
36 def doctest_multiline2():
32 """Multiline examples that define functions and print output.
37 """Multiline examples that define functions and print output.
33
38
@@ -42,5 +42,5 b' def doctest_refs():'
42 """DocTest reference holding issues when running scripts.
42 """DocTest reference holding issues when running scripts.
43
43
44 In [32]: run show_refs.py
44 In [32]: run show_refs.py
45 c referrers: [<type 'dict'>]
45 c referrers: [<... 'dict'>]
46 """
46 """
@@ -46,11 +46,13 b' Authors'
46 #-----------------------------------------------------------------------------
46 #-----------------------------------------------------------------------------
47
47
48 from IPython.testing.ipunittest import ipdoctest, ipdocstring
48 from IPython.testing.ipunittest import ipdoctest, ipdocstring
49 from IPython.utils.py3compat import doctest_refactor_print
49
50
50 #-----------------------------------------------------------------------------
51 #-----------------------------------------------------------------------------
51 # Test classes and functions
52 # Test classes and functions
52 #-----------------------------------------------------------------------------
53 #-----------------------------------------------------------------------------
53 @ipdoctest
54 @ipdoctest
55 @doctest_refactor_print
54 def simple_dt():
56 def simple_dt():
55 """
57 """
56 >>> print 1+1
58 >>> print 1+1
@@ -59,16 +61,20 b' def simple_dt():'
59
61
60
62
61 @ipdoctest
63 @ipdoctest
64 @doctest_refactor_print
62 def ipdt_flush():
65 def ipdt_flush():
63 """
66 """
64 In [20]: print 1
67 In [20]: print 1
65 1
68 1
66
69
67 In [26]: for i in range(10):
70 In [26]: for i in range(4):
68 ....: print i,
71 ....: print i
69 ....:
72 ....:
70 ....:
73 ....:
71 0 1 2 3 4 5 6 7 8 9
74 0
75 1
76 2
77 3
72
78
73 In [27]: 3+4
79 In [27]: 3+4
74 Out[27]: 7
80 Out[27]: 7
@@ -76,16 +82,20 b' Out[27]: 7'
76
82
77
83
78 @ipdoctest
84 @ipdoctest
85 @doctest_refactor_print
79 def ipdt_indented_test():
86 def ipdt_indented_test():
80 """
87 """
81 In [20]: print 1
88 In [20]: print 1
82 1
89 1
83
90
84 In [26]: for i in range(10):
91 In [26]: for i in range(4):
85 ....: print i,
92 ....: print i
86 ....:
93 ....:
87 ....:
94 ....:
88 0 1 2 3 4 5 6 7 8 9
95 0
96 1
97 2
98 3
89
99
90 In [27]: 3+4
100 In [27]: 3+4
91 Out[27]: 7
101 Out[27]: 7
@@ -100,21 +110,26 b' class Foo(object):'
100 """
110 """
101
111
102 @ipdocstring
112 @ipdocstring
113 @doctest_refactor_print
103 def ipdt_method(self):
114 def ipdt_method(self):
104 """
115 """
105 In [20]: print 1
116 In [20]: print 1
106 1
117 1
107
118
108 In [26]: for i in range(10):
119 In [26]: for i in range(4):
109 ....: print i,
120 ....: print i
110 ....:
121 ....:
111 ....:
122 ....:
112 0 1 2 3 4 5 6 7 8 9
123 0
124 1
125 2
126 3
113
127
114 In [27]: 3+4
128 In [27]: 3+4
115 Out[27]: 7
129 Out[27]: 7
116 """
130 """
117
131
132 @doctest_refactor_print
118 def normaldt_method(self):
133 def normaldt_method(self):
119 """
134 """
120 >>> print 1+1
135 >>> print 1+1
General Comments 0
You need to be logged in to leave comments. Login now