Show More
@@ -14,7 +14,6 b' from IPython.testing.globalipapp import get_ipython' | |||||
14 | ip = get_ipython() |
|
14 | ip = get_ipython() | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | @py3compat.doctest_refactor_print |
|
|||
18 | def doctest_autocall(): |
|
17 | def doctest_autocall(): | |
19 | """ |
|
18 | """ | |
20 | In [1]: def f1(a,b,c): |
|
19 | In [1]: def f1(a,b,c): | |
@@ -39,7 +38,7 b' def doctest_autocall():' | |||||
39 |
|
38 | |||
40 | In [7]: assert _ == 'abc' |
|
39 | In [7]: assert _ == 'abc' | |
41 |
|
40 | |||
42 |
In [8]: print |
|
41 | In [8]: print(_) | |
43 | abc |
|
42 | abc | |
44 |
|
43 | |||
45 | In [9]: /f1 1,2,3 |
|
44 | In [9]: /f1 1,2,3 |
@@ -26,7 +26,6 b' from IPython.core.magic import (Magics, magics_class, line_magic,' | |||||
26 | from IPython.core.magics import execution, script, code, logging |
|
26 | from IPython.core.magics import execution, script, code, logging | |
27 | from IPython.testing import decorators as dec |
|
27 | from IPython.testing import decorators as dec | |
28 | from IPython.testing import tools as tt |
|
28 | from IPython.testing import tools as tt | |
29 | from IPython.utils import py3compat |
|
|||
30 | from IPython.utils.io import capture_output |
|
29 | from IPython.utils.io import capture_output | |
31 | from IPython.utils.tempdir import TemporaryDirectory |
|
30 | from IPython.utils.tempdir import TemporaryDirectory | |
32 | from IPython.utils.process import find_cmd |
|
31 | from IPython.utils.process import find_cmd | |
@@ -304,12 +303,10 b' def test_macro_run():' | |||||
304 | """Test that we can run a multi-line macro successfully.""" |
|
303 | """Test that we can run a multi-line macro successfully.""" | |
305 | ip = get_ipython() |
|
304 | ip = get_ipython() | |
306 | ip.history_manager.reset() |
|
305 | ip.history_manager.reset() | |
307 |
cmds = ["a=10", "a+=1", |
|
306 | cmds = ["a=10", "a+=1", "print(a)", "%macro test 2-3"] | |
308 | "%macro test 2-3"] |
|
|||
309 | for cmd in cmds: |
|
307 | for cmd in cmds: | |
310 | ip.run_cell(cmd, store_history=True) |
|
308 | ip.run_cell(cmd, store_history=True) | |
311 | nt.assert_equal(ip.user_ns["test"].value, |
|
309 | nt.assert_equal(ip.user_ns["test"].value, "a+=1\nprint(a)\n") | |
312 | py3compat.doctest_refactor_print("a+=1\nprint a\n")) |
|
|||
313 | with tt.AssertPrints("12"): |
|
310 | with tt.AssertPrints("12"): | |
314 | ip.run_cell("test") |
|
311 | ip.run_cell("test") | |
315 | with tt.AssertPrints("13"): |
|
312 | with tt.AssertPrints("13"): | |
@@ -532,7 +529,6 b' def test_whos():' | |||||
532 | _ip.user_ns['a'] = A() |
|
529 | _ip.user_ns['a'] = A() | |
533 | _ip.magic("whos") |
|
530 | _ip.magic("whos") | |
534 |
|
531 | |||
535 | @py3compat.u_format |
|
|||
536 | def doctest_precision(): |
|
532 | def doctest_precision(): | |
537 | """doctest for %precision |
|
533 | """doctest for %precision | |
538 |
|
534 |
@@ -34,7 +34,6 b' from IPython.core.profiledir import ProfileDir' | |||||
34 |
|
34 | |||
35 | from IPython.testing import decorators as dec |
|
35 | from IPython.testing import decorators as dec | |
36 | from IPython.testing import tools as tt |
|
36 | from IPython.testing import tools as tt | |
37 | from IPython.utils import py3compat |
|
|||
38 | from IPython.utils.process import getoutput |
|
37 | from IPython.utils.process import getoutput | |
39 | from IPython.utils.tempdir import TemporaryDirectory |
|
38 | from IPython.utils.tempdir import TemporaryDirectory | |
40 |
|
39 | |||
@@ -100,15 +99,14 b' class ProfileStartupTest(TestCase):' | |||||
100 | f.write(startup) |
|
99 | f.write(startup) | |
101 | # write simple test file, to check that the startup file was run |
|
100 | # write simple test file, to check that the startup file was run | |
102 | with open(self.fname, 'w') as f: |
|
101 | with open(self.fname, 'w') as f: | |
103 | f.write(py3compat.doctest_refactor_print(test)) |
|
102 | f.write(test) | |
104 |
|
103 | |||
105 | def validate(self, output): |
|
104 | def validate(self, output): | |
106 | tt.ipexec_validate(self.fname, output, '', options=self.options) |
|
105 | tt.ipexec_validate(self.fname, output, '', options=self.options) | |
107 |
|
106 | |||
108 | @dec.skipif(win32_without_pywin32(), "Test requires pywin32 on Windows") |
|
107 | @dec.skipif(win32_without_pywin32(), "Test requires pywin32 on Windows") | |
109 | def test_startup_py(self): |
|
108 | def test_startup_py(self): | |
110 | self.init('00-start.py', 'zzz=123\n', |
|
109 | self.init('00-start.py', 'zzz=123\n', 'print(zzz)\n') | |
111 | py3compat.doctest_refactor_print('print zzz\n')) |
|
|||
112 | self.validate('123') |
|
110 | self.validate('123') | |
113 |
|
111 | |||
114 | @dec.skipif(win32_without_pywin32(), "Test requires pywin32 on Windows") |
|
112 | @dec.skipif(win32_without_pywin32(), "Test requires pywin32 on Windows") |
@@ -31,7 +31,6 b' from nose import SkipTest' | |||||
31 |
|
31 | |||
32 | from IPython.testing import decorators as dec |
|
32 | from IPython.testing import decorators as dec | |
33 | from IPython.testing import tools as tt |
|
33 | from IPython.testing import tools as tt | |
34 | from IPython.utils import py3compat |
|
|||
35 | from IPython.utils.io import capture_output |
|
34 | from IPython.utils.io import capture_output | |
36 | from IPython.utils.tempdir import TemporaryDirectory |
|
35 | from IPython.utils.tempdir import TemporaryDirectory | |
37 | from IPython.core import debugger |
|
36 | from IPython.core import debugger | |
@@ -145,13 +144,12 b' def doctest_run_option_parser_for_windows():' | |||||
145 | """ |
|
144 | """ | |
146 |
|
145 | |||
147 |
|
146 | |||
148 | @py3compat.doctest_refactor_print |
|
|||
149 | def doctest_reset_del(): |
|
147 | def doctest_reset_del(): | |
150 | """Test that resetting doesn't cause errors in __del__ methods. |
|
148 | """Test that resetting doesn't cause errors in __del__ methods. | |
151 |
|
149 | |||
152 | In [2]: class A(object): |
|
150 | In [2]: class A(object): | |
153 | ...: def __del__(self): |
|
151 | ...: def __del__(self): | |
154 |
...: print |
|
152 | ...: print(str("Hi")) | |
155 | ...: |
|
153 | ...: | |
156 |
|
154 | |||
157 | In [3]: a = A() |
|
155 | In [3]: a = A() | |
@@ -248,9 +246,9 b' class TestMagicRunSimple(tt.TempFileMixin):' | |||||
248 | raise SkipTest("Test requires pywin32") |
|
246 | raise SkipTest("Test requires pywin32") | |
249 | src = ("class A(object):\n" |
|
247 | src = ("class A(object):\n" | |
250 | " def __del__(self):\n" |
|
248 | " def __del__(self):\n" | |
251 |
" print |
|
249 | " print('object A deleted')\n" | |
252 | "a = A()\n") |
|
250 | "a = A()\n") | |
253 | self.mktmp(py3compat.doctest_refactor_print(src)) |
|
251 | self.mktmp(src) | |
254 | if dec.module_not_available('sqlite3'): |
|
252 | if dec.module_not_available('sqlite3'): | |
255 | err = 'WARNING: IPython History requires SQLite, your history will not be saved\n' |
|
253 | err = 'WARNING: IPython History requires SQLite, your history will not be saved\n' | |
256 | else: |
|
254 | else: |
@@ -46,29 +46,26 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 |
|
|||
50 |
|
49 | |||
51 | #----------------------------------------------------------------------------- |
|
50 | #----------------------------------------------------------------------------- | |
52 | # Test classes and functions |
|
51 | # Test classes and functions | |
53 | #----------------------------------------------------------------------------- |
|
52 | #----------------------------------------------------------------------------- | |
54 | @ipdoctest |
|
53 | @ipdoctest | |
55 | @doctest_refactor_print |
|
|||
56 | def simple_dt(): |
|
54 | def simple_dt(): | |
57 | """ |
|
55 | """ | |
58 |
>>> print |
|
56 | >>> print(1+1) | |
59 | 2 |
|
57 | 2 | |
60 | """ |
|
58 | """ | |
61 |
|
59 | |||
62 |
|
60 | |||
63 | @ipdoctest |
|
61 | @ipdoctest | |
64 | @doctest_refactor_print |
|
|||
65 | def ipdt_flush(): |
|
62 | def ipdt_flush(): | |
66 | """ |
|
63 | """ | |
67 |
In [20]: print |
|
64 | In [20]: print(1) | |
68 | 1 |
|
65 | 1 | |
69 |
|
66 | |||
70 | In [26]: for i in range(4): |
|
67 | In [26]: for i in range(4): | |
71 |
....: print |
|
68 | ....: print(i) | |
72 | ....: |
|
69 | ....: | |
73 | ....: |
|
70 | ....: | |
74 | 0 |
|
71 | 0 | |
@@ -82,14 +79,13 b' Out[27]: 7' | |||||
82 |
|
79 | |||
83 |
|
80 | |||
84 | @ipdoctest |
|
81 | @ipdoctest | |
85 | @doctest_refactor_print |
|
|||
86 | def ipdt_indented_test(): |
|
82 | def ipdt_indented_test(): | |
87 | """ |
|
83 | """ | |
88 |
In [20]: print |
|
84 | In [20]: print(1) | |
89 | 1 |
|
85 | 1 | |
90 |
|
86 | |||
91 | In [26]: for i in range(4): |
|
87 | In [26]: for i in range(4): | |
92 |
....: print |
|
88 | ....: print(i) | |
93 | ....: |
|
89 | ....: | |
94 | ....: |
|
90 | ....: | |
95 | 0 |
|
91 | 0 | |
@@ -110,14 +106,13 b' class Foo(object):' | |||||
110 | """ |
|
106 | """ | |
111 |
|
107 | |||
112 | @ipdocstring |
|
108 | @ipdocstring | |
113 | @doctest_refactor_print |
|
|||
114 | def ipdt_method(self): |
|
109 | def ipdt_method(self): | |
115 | """ |
|
110 | """ | |
116 |
In [20]: print |
|
111 | In [20]: print(1) | |
117 | 1 |
|
112 | 1 | |
118 |
|
113 | |||
119 | In [26]: for i in range(4): |
|
114 | In [26]: for i in range(4): | |
120 |
....: print |
|
115 | ....: print(i) | |
121 | ....: |
|
116 | ....: | |
122 | ....: |
|
117 | ....: | |
123 | 0 |
|
118 | 0 | |
@@ -129,9 +124,8 b' class Foo(object):' | |||||
129 | Out[27]: 7 |
|
124 | Out[27]: 7 | |
130 | """ |
|
125 | """ | |
131 |
|
126 | |||
132 | @doctest_refactor_print |
|
|||
133 | def normaldt_method(self): |
|
127 | def normaldt_method(self): | |
134 | """ |
|
128 | """ | |
135 |
>>> print |
|
129 | >>> print(1+1) | |
136 | 2 |
|
130 | 2 | |
137 | """ |
|
131 | """ |
@@ -21,7 +21,6 b' from IPython.utils import py3compat' | |||||
21 | # Code |
|
21 | # Code | |
22 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
23 |
|
23 | |||
24 | @py3compat.doctest_refactor_print |
|
|||
25 | def extract_vars(*names,**kw): |
|
24 | def extract_vars(*names,**kw): | |
26 | """Extract a set of variables by name from another frame. |
|
25 | """Extract a set of variables by name from another frame. | |
27 |
|
26 |
@@ -17,7 +17,6 b' from warnings import warn' | |||||
17 |
|
17 | |||
18 | from IPython.utils.decorators import undoc |
|
18 | from IPython.utils.decorators import undoc | |
19 | from .capture import CapturedIO, capture_output |
|
19 | from .capture import CapturedIO, capture_output | |
20 | from .py3compat import input |
|
|||
21 |
|
20 | |||
22 | @undoc |
|
21 | @undoc | |
23 | class IOStream: |
|
22 | class IOStream: |
@@ -21,7 +21,7 b' import sys' | |||||
21 | import subprocess |
|
21 | import subprocess | |
22 |
|
22 | |||
23 | from IPython.core import release |
|
23 | from IPython.core import release | |
24 |
from IPython.utils import |
|
24 | from IPython.utils import _sysinfo, encoding | |
25 |
|
25 | |||
26 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
27 | # Code |
|
27 | # Code | |
@@ -98,7 +98,6 b' def get_sys_info():' | |||||
98 | path = p.realpath(p.dirname(p.abspath(p.join(__file__, '..')))) |
|
98 | path = p.realpath(p.dirname(p.abspath(p.join(__file__, '..')))) | |
99 | return pkg_info(path) |
|
99 | return pkg_info(path) | |
100 |
|
100 | |||
101 | @py3compat.doctest_refactor_print |
|
|||
102 | def sys_info(): |
|
101 | def sys_info(): | |
103 | """Return useful information about IPython and the system, as a string. |
|
102 | """Return useful information about IPython and the system, as a string. | |
104 |
|
103 | |||
@@ -106,7 +105,7 b' def sys_info():' | |||||
106 | -------- |
|
105 | -------- | |
107 | :: |
|
106 | :: | |
108 |
|
107 | |||
109 |
In [2]: print |
|
108 | In [2]: print(sys_info()) | |
110 | {'commit_hash': '144fdae', # random |
|
109 | {'commit_hash': '144fdae', # random | |
111 | 'commit_source': 'repository', |
|
110 | 'commit_source': 'repository', | |
112 | 'ipython_path': '/home/fperez/usr/lib/python2.6/site-packages/IPython', |
|
111 | 'ipython_path': '/home/fperez/usr/lib/python2.6/site-packages/IPython', |
@@ -18,7 +18,6 b' import nose.tools as nt' | |||||
18 |
|
18 | |||
19 | from IPython.testing.decorators import skipif, skip_win32 |
|
19 | from IPython.testing.decorators import skipif, skip_win32 | |
20 | from IPython.utils.io import IOStream, Tee, capture_output |
|
20 | from IPython.utils.io import IOStream, Tee, capture_output | |
21 | from IPython.utils.py3compat import doctest_refactor_print |
|
|||
22 | from IPython.utils.tempdir import TemporaryDirectory |
|
21 | from IPython.utils.tempdir import TemporaryDirectory | |
23 |
|
22 | |||
24 |
|
23 | |||
@@ -59,7 +58,7 b' class TeeTestCase(unittest.TestCase):' | |||||
59 | def test_io_init(): |
|
58 | def test_io_init(): | |
60 | """Test that io.stdin/out/err exist at startup""" |
|
59 | """Test that io.stdin/out/err exist at startup""" | |
61 | for name in ('stdin', 'stdout', 'stderr'): |
|
60 | for name in ('stdin', 'stdout', 'stderr'): | |
62 |
cmd = |
|
61 | cmd = "from IPython.utils import io;print(io.%s.__class__)"%name | |
63 | p = Popen([sys.executable, '-c', cmd], |
|
62 | p = Popen([sys.executable, '-c', cmd], | |
64 | stdout=PIPE) |
|
63 | stdout=PIPE) | |
65 | p.wait() |
|
64 | p.wait() |
General Comments 0
You need to be logged in to leave comments.
Login now