Show More
@@ -8,23 +8,21 artificially). | |||
|
8 | 8 | """ |
|
9 | 9 | from IPython.utils.py3compat import doctest_refactor_print |
|
10 | 10 | |
|
11 | @doctest_refactor_print | |
|
12 | 11 | def doctest_simple(): |
|
13 | 12 | """ipdoctest must handle simple inputs |
|
14 | 13 | |
|
15 | 14 | In [1]: 1 |
|
16 | 15 | Out[1]: 1 |
|
17 | 16 | |
|
18 |
In [2]: print |
|
|
17 | In [2]: print(1) | |
|
19 | 18 | 1 |
|
20 | 19 | """ |
|
21 | 20 | |
|
22 | @doctest_refactor_print | |
|
23 | 21 | def doctest_multiline1(): |
|
24 | 22 | """The ipdoctest machinery must handle multiline examples gracefully. |
|
25 | 23 | |
|
26 | 24 | In [2]: for i in range(4): |
|
27 |
...: print |
|
|
25 | ...: print(i) | |
|
28 | 26 | ...: |
|
29 | 27 | 0 |
|
30 | 28 | 1 |
@@ -32,7 +30,6 def doctest_multiline1(): | |||
|
32 | 30 | 3 |
|
33 | 31 | """ |
|
34 | 32 | |
|
35 | @doctest_refactor_print | |
|
36 | 33 | def doctest_multiline2(): |
|
37 | 34 | """Multiline examples that define functions and print output. |
|
38 | 35 | |
@@ -44,7 +41,7 def doctest_multiline2(): | |||
|
44 | 41 | Out[8]: 2 |
|
45 | 42 | |
|
46 | 43 | In [9]: def g(x): |
|
47 |
...: print |
|
|
44 | ...: print('x is:',x) | |
|
48 | 45 | ...: |
|
49 | 46 | |
|
50 | 47 | In [10]: g(1) |
@@ -193,14 +193,6 def _print_statement_sub(match): | |||
|
193 | 193 | expr = match.groups('expr') |
|
194 | 194 | return "print(%s)" % expr |
|
195 | 195 | |
|
196 | @_modify_str_or_docstring | |
|
197 | def doctest_refactor_print(doc): | |
|
198 | """Refactor 'print x' statements in a doctest to print(x) style. 2to3 | |
|
199 | unfortunately doesn't pick up on our doctests. | |
|
200 | ||
|
201 | Can accept a string or a function, so it can be used as a decorator.""" | |
|
202 | return _print_statement_re.sub(_print_statement_sub, doc) | |
|
203 | ||
|
204 | 196 | # Abstract u'abc' syntax: |
|
205 | 197 | @_modify_str_or_docstring |
|
206 | 198 | def u_format(s): |
General Comments 0
You need to be logged in to leave comments.
Login now