Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0707dc5

Browse files
committed
Various fixes for tests in IPython.testing.
1 parent c4afd4e commit 0707dc5

4 files changed

Lines changed: 40 additions & 18 deletions

File tree

IPython/testing/plugin/dtexample.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This file just contains doctests both using plain python and IPython prompts.
44
All tests should be loaded by nose.
55
"""
6+
from IPython.utils.py3compat import doctest_refactor_print
67

78
def pyfunc():
89
"""Some pure python tests...
@@ -23,7 +24,7 @@ def pyfunc():
2324
"""
2425
return 'pyfunc'
2526

26-
27+
@doctest_refactor_print
2728
def ipfunc():
2829
"""Some ipython tests...
2930
@@ -127,7 +128,7 @@ def random_all():
127128
"""
128129
pass
129130

130-
131+
@doctest_refactor_print
131132
def iprand():
132133
"""Some ipython tests with random output.
133134
@@ -142,7 +143,7 @@ def iprand():
142143
"""
143144
return 'iprand'
144145

145-
146+
@doctest_refactor_print
146147
def iprand_all():
147148
"""Some ipython tests with fully random output.
148149
@@ -160,3 +161,4 @@ def iprand_all():
160161
return 'iprand_all'
161162

162163

164+

IPython/testing/plugin/test_ipdoctest.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
empty function call is counted as a test, which just inflates tests numbers
77
artificially).
88
"""
9+
from IPython.utils.py3compat import doctest_refactor_print
910

11+
@doctest_refactor_print
1012
def doctest_simple():
1113
"""ipdoctest must handle simple inputs
1214
@@ -17,17 +19,20 @@ def doctest_simple():
1719
1
1820
"""
1921

20-
22+
@doctest_refactor_print
2123
def doctest_multiline1():
2224
"""The ipdoctest machinery must handle multiline examples gracefully.
2325
24-
In [2]: for i in range(10):
25-
...: print i,
26+
In [2]: for i in range(4):
27+
...: print i
2628
...:
27-
0 1 2 3 4 5 6 7 8 9
29+
0
30+
1
31+
2
32+
3
2833
"""
2934

30-
35+
@doctest_refactor_print
3136
def doctest_multiline2():
3237
"""Multiline examples that define functions and print output.
3338

IPython/testing/plugin/test_refs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ def doctest_refs():
4242
"""DocTest reference holding issues when running scripts.
4343
4444
In [32]: run show_refs.py
45-
c referrers: [<type 'dict'>]
45+
c referrers: [<... 'dict'>]
4646
"""

IPython/testing/tests/test_ipunittest.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@
4646
#-----------------------------------------------------------------------------
4747

4848
from IPython.testing.ipunittest import ipdoctest, ipdocstring
49+
from IPython.utils.py3compat import doctest_refactor_print
4950

5051
#-----------------------------------------------------------------------------
5152
# Test classes and functions
5253
#-----------------------------------------------------------------------------
5354
@ipdoctest
55+
@doctest_refactor_print
5456
def simple_dt():
5557
"""
5658
>>> print 1+1
@@ -59,33 +61,41 @@ def simple_dt():
5961

6062

6163
@ipdoctest
64+
@doctest_refactor_print
6265
def ipdt_flush():
6366
"""
6467
In [20]: print 1
6568
1
6669
67-
In [26]: for i in range(10):
68-
....: print i,
70+
In [26]: for i in range(4):
71+
....: print i
6972
....:
7073
....:
71-
0 1 2 3 4 5 6 7 8 9
74+
0
75+
1
76+
2
77+
3
7278
7379
In [27]: 3+4
7480
Out[27]: 7
7581
"""
7682

7783

7884
@ipdoctest
85+
@doctest_refactor_print
7986
def ipdt_indented_test():
8087
"""
8188
In [20]: print 1
8289
1
8390
84-
In [26]: for i in range(10):
85-
....: print i,
91+
In [26]: for i in range(4):
92+
....: print i
8693
....:
8794
....:
88-
0 1 2 3 4 5 6 7 8 9
95+
0
96+
1
97+
2
98+
3
8999
90100
In [27]: 3+4
91101
Out[27]: 7
@@ -100,21 +110,26 @@ class Foo(object):
100110
"""
101111

102112
@ipdocstring
113+
@doctest_refactor_print
103114
def ipdt_method(self):
104115
"""
105116
In [20]: print 1
106117
1
107118
108-
In [26]: for i in range(10):
109-
....: print i,
119+
In [26]: for i in range(4):
120+
....: print i
110121
....:
111122
....:
112-
0 1 2 3 4 5 6 7 8 9
123+
0
124+
1
125+
2
126+
3
113127
114128
In [27]: 3+4
115129
Out[27]: 7
116130
"""
117131

132+
@doctest_refactor_print
118133
def normaldt_method(self):
119134
"""
120135
>>> print 1+1

0 commit comments

Comments
 (0)