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

Skip to content

Commit 69a22c2

Browse files
committed
remove some py3compat usage
1 parent dda5238 commit 69a22c2

9 files changed

Lines changed: 19 additions & 38 deletions

File tree

IPython/core/tests/test_autocall.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
ip = get_ipython()
1515

1616

17-
@py3compat.doctest_refactor_print
1817
def doctest_autocall():
1918
"""
2019
In [1]: def f1(a,b,c):
@@ -39,7 +38,7 @@ def doctest_autocall():
3938
4039
In [7]: assert _ == 'abc'
4140
42-
In [8]: print _
41+
In [8]: print(_)
4342
abc
4443
4544
In [9]: /f1 1,2,3

IPython/core/tests/test_magic.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from IPython.core.magics import execution, script, code, logging
2727
from IPython.testing import decorators as dec
2828
from IPython.testing import tools as tt
29-
from IPython.utils import py3compat
3029
from IPython.utils.io import capture_output
3130
from IPython.utils.tempdir import TemporaryDirectory
3231
from IPython.utils.process import find_cmd
@@ -304,12 +303,10 @@ def test_macro_run():
304303
"""Test that we can run a multi-line macro successfully."""
305304
ip = get_ipython()
306305
ip.history_manager.reset()
307-
cmds = ["a=10", "a+=1", py3compat.doctest_refactor_print("print a"),
308-
"%macro test 2-3"]
306+
cmds = ["a=10", "a+=1", "print(a)", "%macro test 2-3"]
309307
for cmd in cmds:
310308
ip.run_cell(cmd, store_history=True)
311-
nt.assert_equal(ip.user_ns["test"].value,
312-
py3compat.doctest_refactor_print("a+=1\nprint a\n"))
309+
nt.assert_equal(ip.user_ns["test"].value, "a+=1\nprint(a)\n")
313310
with tt.AssertPrints("12"):
314311
ip.run_cell("test")
315312
with tt.AssertPrints("13"):
@@ -532,7 +529,6 @@ def __repr__(self):
532529
_ip.user_ns['a'] = A()
533530
_ip.magic("whos")
534531

535-
@py3compat.u_format
536532
def doctest_precision():
537533
"""doctest for %precision
538534

IPython/core/tests/test_profile.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
from IPython.testing import decorators as dec
3636
from IPython.testing import tools as tt
37-
from IPython.utils import py3compat
3837
from IPython.utils.process import getoutput
3938
from IPython.utils.tempdir import TemporaryDirectory
4039

@@ -100,15 +99,14 @@ def init(self, startup_file, startup, test):
10099
f.write(startup)
101100
# write simple test file, to check that the startup file was run
102101
with open(self.fname, 'w') as f:
103-
f.write(py3compat.doctest_refactor_print(test))
102+
f.write(test)
104103

105104
def validate(self, output):
106105
tt.ipexec_validate(self.fname, output, '', options=self.options)
107106

108107
@dec.skipif(win32_without_pywin32(), "Test requires pywin32 on Windows")
109108
def test_startup_py(self):
110-
self.init('00-start.py', 'zzz=123\n',
111-
py3compat.doctest_refactor_print('print zzz\n'))
109+
self.init('00-start.py', 'zzz=123\n', 'print(zzz)\n')
112110
self.validate('123')
113111

114112
@dec.skipif(win32_without_pywin32(), "Test requires pywin32 on Windows")

IPython/core/tests/test_run.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
from IPython.testing import decorators as dec
3333
from IPython.testing import tools as tt
34-
from IPython.utils import py3compat
3534
from IPython.utils.io import capture_output
3635
from IPython.utils.tempdir import TemporaryDirectory
3736
from IPython.core import debugger
@@ -145,13 +144,12 @@ def doctest_run_option_parser_for_windows():
145144
"""
146145

147146

148-
@py3compat.doctest_refactor_print
149147
def doctest_reset_del():
150148
"""Test that resetting doesn't cause errors in __del__ methods.
151149
152150
In [2]: class A(object):
153151
...: def __del__(self):
154-
...: print str("Hi")
152+
...: print(str("Hi"))
155153
...:
156154
157155
In [3]: a = A()
@@ -248,9 +246,9 @@ def test_obj_del(self):
248246
raise SkipTest("Test requires pywin32")
249247
src = ("class A(object):\n"
250248
" def __del__(self):\n"
251-
" print 'object A deleted'\n"
249+
" print('object A deleted')\n"
252250
"a = A()\n")
253-
self.mktmp(py3compat.doctest_refactor_print(src))
251+
self.mktmp(src)
254252
if dec.module_not_available('sqlite3'):
255253
err = 'WARNING: IPython History requires SQLite, your history will not be saved\n'
256254
else:

IPython/testing/tests/test_ipunittest.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,26 @@
4646
#-----------------------------------------------------------------------------
4747

4848
from IPython.testing.ipunittest import ipdoctest, ipdocstring
49-
from IPython.utils.py3compat import doctest_refactor_print
5049

5150
#-----------------------------------------------------------------------------
5251
# Test classes and functions
5352
#-----------------------------------------------------------------------------
5453
@ipdoctest
55-
@doctest_refactor_print
5654
def simple_dt():
5755
"""
58-
>>> print 1+1
56+
>>> print(1+1)
5957
2
6058
"""
6159

6260

6361
@ipdoctest
64-
@doctest_refactor_print
6562
def ipdt_flush():
6663
"""
67-
In [20]: print 1
64+
In [20]: print(1)
6865
1
6966
7067
In [26]: for i in range(4):
71-
....: print i
68+
....: print(i)
7269
....:
7370
....:
7471
0
@@ -82,14 +79,13 @@ def ipdt_flush():
8279

8380

8481
@ipdoctest
85-
@doctest_refactor_print
8682
def ipdt_indented_test():
8783
"""
88-
In [20]: print 1
84+
In [20]: print(1)
8985
1
9086
9187
In [26]: for i in range(4):
92-
....: print i
88+
....: print(i)
9389
....:
9490
....:
9591
0
@@ -110,14 +106,13 @@ class Foo(object):
110106
"""
111107

112108
@ipdocstring
113-
@doctest_refactor_print
114109
def ipdt_method(self):
115110
"""
116-
In [20]: print 1
111+
In [20]: print(1)
117112
1
118113
119114
In [26]: for i in range(4):
120-
....: print i
115+
....: print(i)
121116
....:
122117
....:
123118
0
@@ -129,9 +124,8 @@ def ipdt_method(self):
129124
Out[27]: 7
130125
"""
131126

132-
@doctest_refactor_print
133127
def normaldt_method(self):
134128
"""
135-
>>> print 1+1
129+
>>> print(1+1)
136130
2
137131
"""

IPython/utils/frame.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# Code
2222
#-----------------------------------------------------------------------------
2323

24-
@py3compat.doctest_refactor_print
2524
def extract_vars(*names,**kw):
2625
"""Extract a set of variables by name from another frame.
2726

IPython/utils/io.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from IPython.utils.decorators import undoc
1919
from .capture import CapturedIO, capture_output
20-
from .py3compat import input
2120

2221
@undoc
2322
class IOStream:

IPython/utils/sysinfo.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import subprocess
2222

2323
from IPython.core import release
24-
from IPython.utils import py3compat, _sysinfo, encoding
24+
from IPython.utils import _sysinfo, encoding
2525

2626
#-----------------------------------------------------------------------------
2727
# Code
@@ -98,15 +98,14 @@ def get_sys_info():
9898
path = p.realpath(p.dirname(p.abspath(p.join(__file__, '..'))))
9999
return pkg_info(path)
100100

101-
@py3compat.doctest_refactor_print
102101
def sys_info():
103102
"""Return useful information about IPython and the system, as a string.
104103
105104
Examples
106105
--------
107106
::
108107
109-
In [2]: print sys_info()
108+
In [2]: print(sys_info())
110109
{'commit_hash': '144fdae', # random
111110
'commit_source': 'repository',
112111
'ipython_path': '/home/fperez/usr/lib/python2.6/site-packages/IPython',

IPython/utils/tests/test_io.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from IPython.testing.decorators import skipif, skip_win32
2020
from IPython.utils.io import IOStream, Tee, capture_output
21-
from IPython.utils.py3compat import doctest_refactor_print
2221
from IPython.utils.tempdir import TemporaryDirectory
2322

2423

@@ -59,7 +58,7 @@ def test(self):
5958
def test_io_init():
6059
"""Test that io.stdin/out/err exist at startup"""
6160
for name in ('stdin', 'stdout', 'stderr'):
62-
cmd = doctest_refactor_print("from IPython.utils import io;print io.%s.__class__"%name)
61+
cmd = "from IPython.utils import io;print(io.%s.__class__)"%name
6362
p = Popen([sys.executable, '-c', cmd],
6463
stdout=PIPE)
6564
p.wait()

0 commit comments

Comments
 (0)