Show More
@@ -6,25 +6,22 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 |
|
|||
10 |
|
9 | |||
11 | @doctest_refactor_print |
|
|||
12 | def doctest_simple(): |
|
10 | def doctest_simple(): | |
13 | """ipdoctest must handle simple inputs |
|
11 | """ipdoctest must handle simple inputs | |
14 |
|
12 | |||
15 | In [1]: 1 |
|
13 | In [1]: 1 | |
16 | Out[1]: 1 |
|
14 | Out[1]: 1 | |
17 |
|
15 | |||
18 |
In [2]: print |
|
16 | In [2]: print(1) | |
19 | 1 |
|
17 | 1 | |
20 | """ |
|
18 | """ | |
21 |
|
19 | |||
22 | @doctest_refactor_print |
|
|||
23 | def doctest_multiline1(): |
|
20 | def doctest_multiline1(): | |
24 | """The ipdoctest machinery must handle multiline examples gracefully. |
|
21 | """The ipdoctest machinery must handle multiline examples gracefully. | |
25 |
|
22 | |||
26 | In [2]: for i in range(4): |
|
23 | In [2]: for i in range(4): | |
27 |
...: print |
|
24 | ...: print(i) | |
28 | ...: |
|
25 | ...: | |
29 | 0 |
|
26 | 0 | |
30 | 1 |
|
27 | 1 | |
@@ -32,7 +29,6 b' def doctest_multiline1():' | |||||
32 | 3 |
|
29 | 3 | |
33 | """ |
|
30 | """ | |
34 |
|
31 | |||
35 | @doctest_refactor_print |
|
|||
36 | def doctest_multiline2(): |
|
32 | def doctest_multiline2(): | |
37 | """Multiline examples that define functions and print output. |
|
33 | """Multiline examples that define functions and print output. | |
38 |
|
34 | |||
@@ -44,7 +40,7 b' def doctest_multiline2():' | |||||
44 | Out[8]: 2 |
|
40 | Out[8]: 2 | |
45 |
|
41 | |||
46 | In [9]: def g(x): |
|
42 | In [9]: def g(x): | |
47 |
...: print |
|
43 | ...: print('x is:',x) | |
48 | ...: |
|
44 | ...: | |
49 |
|
45 | |||
50 | In [10]: g(1) |
|
46 | In [10]: g(1) |
@@ -193,14 +193,6 b' def _print_statement_sub(match):' | |||||
193 | expr = match.groups('expr') |
|
193 | expr = match.groups('expr') | |
194 | return "print(%s)" % expr |
|
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 | # Abstract u'abc' syntax: |
|
196 | # Abstract u'abc' syntax: | |
205 | @_modify_str_or_docstring |
|
197 | @_modify_str_or_docstring | |
206 | def u_format(s): |
|
198 | def u_format(s): |
General Comments 0
You need to be logged in to leave comments.
Login now