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

Skip to content

Commit 7131f84

Browse files
committed
Fix a bunch of doctests with the -d option of refactor.py.
We still have 27 failing tests (down from 39).
1 parent 4502c80 commit 7131f84

24 files changed

Lines changed: 217 additions & 217 deletions

Lib/Cookie.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@
8080
>>> C = Cookie.SmartCookie()
8181
>>> C["rocky"] = "road"
8282
>>> C["rocky"]["path"] = "/cookie"
83-
>>> print(C.output(header="Cookie:"))
83+
>>> print((C.output(header="Cookie:")))
8484
Cookie: rocky=road; Path=/cookie
85-
>>> print(C.output(attrs=[], header="Cookie:"))
85+
>>> print((C.output(attrs=[], header="Cookie:")))
8686
Cookie: rocky=road
8787
8888
The load() method of a Cookie extracts cookies from a string. In a
@@ -100,7 +100,7 @@
100100
101101
>>> C = Cookie.SmartCookie()
102102
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
103-
>>> print(C)
103+
>>> print((C))
104104
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
105105
106106
Each element of the Cookie also supports all of the RFC 2109
@@ -110,7 +110,7 @@
110110
>>> C = Cookie.SmartCookie()
111111
>>> C["oreo"] = "doublestuff"
112112
>>> C["oreo"]["path"] = "/"
113-
>>> print(C)
113+
>>> print((C))
114114
Set-Cookie: oreo=doublestuff; Path=/
115115
116116
Each dictionary element has a 'value' attribute, which gives you
@@ -198,7 +198,7 @@
198198
fact, this simply returns a SmartCookie.
199199
200200
>>> C = Cookie.Cookie()
201-
>>> print(C.__class__.__name__)
201+
>>> print((C.__class__.__name__))
202202
SmartCookie
203203
204204

Lib/ctypes/test/test_objects.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
>>> from ctypes import *
1515
>>> array = (c_char_p * 5)()
16-
>>> print array._objects
16+
>>> print(array._objects)
1717
None
1818
>>>
1919
@@ -34,14 +34,14 @@
3434
... _fields_ = [("x", c_int), ("y", c_int), ("array", c_char_p * 5)]
3535
...
3636
>>> x = X()
37-
>>> print x._objects
37+
>>> print(x._objects)
3838
None
3939
>>>
4040
4141
The'array' attribute of the 'x' object shares part of the memory buffer
4242
of 'x' ('_b_base_' is either None, or the root object owning the memory block):
4343
44-
>>> print x.array._b_base_ # doctest: +ELLIPSIS
44+
>>> print(x.array._b_base_) # doctest: +ELLIPSIS
4545
<ctypes.test.test_objects.X object at 0x...>
4646
>>>
4747

Lib/decimal.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,61 +56,61 @@
5656
>>> Decimal("12.34") + Decimal("3.87") - Decimal("18.41")
5757
Decimal("-2.20")
5858
>>> dig = Decimal(1)
59-
>>> print dig / Decimal(3)
59+
>>> print(dig / Decimal(3))
6060
0.333333333
6161
>>> getcontext().prec = 18
62-
>>> print dig / Decimal(3)
62+
>>> print(dig / Decimal(3))
6363
0.333333333333333333
64-
>>> print dig.sqrt()
64+
>>> print(dig.sqrt())
6565
1
66-
>>> print Decimal(3).sqrt()
66+
>>> print(Decimal(3).sqrt())
6767
1.73205080756887729
68-
>>> print Decimal(3) ** 123
68+
>>> print(Decimal(3) ** 123)
6969
4.85192780976896427E+58
7070
>>> inf = Decimal(1) / Decimal(0)
71-
>>> print inf
71+
>>> print(inf)
7272
Infinity
7373
>>> neginf = Decimal(-1) / Decimal(0)
74-
>>> print neginf
74+
>>> print(neginf)
7575
-Infinity
76-
>>> print neginf + inf
76+
>>> print(neginf + inf)
7777
NaN
78-
>>> print neginf * inf
78+
>>> print(neginf * inf)
7979
-Infinity
80-
>>> print dig / 0
80+
>>> print(dig / 0)
8181
Infinity
8282
>>> getcontext().traps[DivisionByZero] = 1
83-
>>> print dig / 0
83+
>>> print(dig / 0)
8484
Traceback (most recent call last):
8585
...
8686
...
8787
...
8888
decimal.DivisionByZero: x / 0
8989
>>> c = Context()
9090
>>> c.traps[InvalidOperation] = 0
91-
>>> print c.flags[InvalidOperation]
91+
>>> print(c.flags[InvalidOperation])
9292
0
9393
>>> c.divide(Decimal(0), Decimal(0))
9494
Decimal("NaN")
9595
>>> c.traps[InvalidOperation] = 1
96-
>>> print c.flags[InvalidOperation]
96+
>>> print(c.flags[InvalidOperation])
9797
1
9898
>>> c.flags[InvalidOperation] = 0
99-
>>> print c.flags[InvalidOperation]
99+
>>> print(c.flags[InvalidOperation])
100100
0
101-
>>> print c.divide(Decimal(0), Decimal(0))
101+
>>> print(c.divide(Decimal(0), Decimal(0)))
102102
Traceback (most recent call last):
103103
...
104104
...
105105
...
106106
decimal.InvalidOperation: 0 / 0
107-
>>> print c.flags[InvalidOperation]
107+
>>> print(c.flags[InvalidOperation])
108108
1
109109
>>> c.flags[InvalidOperation] = 0
110110
>>> c.traps[InvalidOperation] = 0
111-
>>> print c.divide(Decimal(0), Decimal(0))
111+
>>> print(c.divide(Decimal(0), Decimal(0)))
112112
NaN
113-
>>> print c.flags[InvalidOperation]
113+
>>> print(c.flags[InvalidOperation])
114114
1
115115
>>>
116116
"""
@@ -483,19 +483,19 @@ def sin(x):
483483
# as the doctest module doesn't understand __future__ statements
484484
"""
485485
>>> from __future__ import with_statement
486-
>>> print getcontext().prec
486+
>>> print(getcontext().prec)
487487
28
488488
>>> with localcontext():
489489
... ctx = getcontext()
490490
... ctx.prec() += 2
491-
... print ctx.prec
492-
...
491+
... print(ctx.prec)
492+
...
493493
30
494494
>>> with localcontext(ExtendedContext):
495-
... print getcontext().prec
496-
...
495+
... print(getcontext().prec)
496+
...
497497
9
498-
>>> print getcontext().prec
498+
>>> print(getcontext().prec)
499499
28
500500
"""
501501
if ctx is None: ctx = getcontext()

Lib/difflib.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ class SequenceMatcher:
7676
sequences. As a rule of thumb, a .ratio() value over 0.6 means the
7777
sequences are close matches:
7878
79-
>>> print(round(s.ratio(), 3))
79+
>>> print((round(s.ratio(), 3)))
8080
0.866
8181
>>>
8282
8383
If you're only interested in where the sequences match,
8484
.get_matching_blocks() is handy:
8585
8686
>>> for block in s.get_matching_blocks():
87-
... print("a[%d] and b[%d] match for %d elements" % block)
87+
... print(("a[%d] and b[%d] match for %d elements" % block))
8888
a[0] and b[0] match for 8 elements
8989
a[8] and b[17] match for 21 elements
9090
a[29] and b[38] match for 0 elements
@@ -97,7 +97,7 @@ class SequenceMatcher:
9797
use .get_opcodes():
9898
9999
>>> for opcode in s.get_opcodes():
100-
... print("%6s a[%d:%d] b[%d:%d]" % opcode)
100+
... print(("%6s a[%d:%d] b[%d:%d]" % opcode))
101101
equal a[0:8] b[0:8]
102102
insert a[8:8] b[8:17]
103103
equal a[8:29] b[17:38]
@@ -545,8 +545,8 @@ def get_opcodes(self):
545545
>>> b = "abycdf"
546546
>>> s = SequenceMatcher(None, a, b)
547547
>>> for tag, i1, i2, j1, j2 in s.get_opcodes():
548-
... print(("%7s a[%d:%d] (%s) b[%d:%d] (%s)" %
549-
... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])))
548+
... print((("%7s a[%d:%d] (%s) b[%d:%d] (%s)" %
549+
... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2]))))
550550
delete a[0:1] (q) b[0:0] ()
551551
equal a[1:3] (ab) b[0:2] (ab)
552552
replace a[3:4] (x) b[2:3] (y)
@@ -1059,8 +1059,8 @@ def _qformat(self, aline, bline, atags, btags):
10591059
>>> d = Differ()
10601060
>>> results = d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n',
10611061
... ' ^ ^ ^ ', '+ ^ ^ ^ ')
1062-
>>> for line in results: print(repr(line))
1063-
...
1062+
>>> for line in results: print((repr(line)))
1063+
...
10641064
'- \tabcDefghiJkl\n'
10651065
'? \t ^ ^ ^\n'
10661066
'+ \t\tabcdefGhijkl\n'
@@ -1165,7 +1165,7 @@ def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
11651165
... 'zero one tree four'.split(), 'Original', 'Current',
11661166
... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:20:52 2003',
11671167
... lineterm=''):
1168-
... print(line)
1168+
... print((line))
11691169
--- Original Sat Jan 26 23:30:50 1991
11701170
+++ Current Fri Jun 06 10:20:52 2003
11711171
@@ -1,4 +1,4 @@

Lib/distutils/versionpredicate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class VersionPredicate:
4040
The str() of a `VersionPredicate` provides a normalized
4141
human-readable version of the expression::
4242
43-
>>> print v
43+
>>> print(v)
4444
pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3)
4545
4646
The `satisfied_by()` method can be used to determine with a given

Lib/doctest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ class DocTestRunner:
10121012
>>> runner = DocTestRunner(verbose=False)
10131013
>>> tests.sort(key = lambda test: test.name)
10141014
>>> for test in tests:
1015-
... print test.name, '->', runner.run(test)
1015+
... print(test.name, '->', runner.run(test))
10161016
_TestClass -> (0, 2)
10171017
_TestClass.__init__ -> (0, 2)
10181018
_TestClass.get -> (0, 2)
@@ -2419,7 +2419,7 @@ def script_from_examples(s):
24192419
... Ho hum
24202420
... '''
24212421
2422-
>>> print script_from_examples(text)
2422+
>>> print(script_from_examples(text))
24232423
# Here are examples of simple math.
24242424
#
24252425
# Python has super accurate integer addition
@@ -2554,7 +2554,7 @@ def __init__(self, val):
25542554
"""val -> _TestClass object with associated value val.
25552555
25562556
>>> t = _TestClass(123)
2557-
>>> print t.get()
2557+
>>> print(t.get())
25582558
123
25592559
"""
25602560

@@ -2574,7 +2574,7 @@ def get(self):
25742574
"""get() -> return TestClass's associated value.
25752575
25762576
>>> x = _TestClass(-42)
2577-
>>> print x.get()
2577+
>>> print(x.get())
25782578
-42
25792579
"""
25802580

@@ -2606,7 +2606,7 @@ def get(self):
26062606

26072607
"blank lines": r"""
26082608
Blank lines can be marked with <BLANKLINE>:
2609-
>>> print 'foo\n\nbar\n'
2609+
>>> print('foo\n\nbar\n')
26102610
foo
26112611
<BLANKLINE>
26122612
bar
@@ -2616,14 +2616,14 @@ def get(self):
26162616
"ellipsis": r"""
26172617
If the ellipsis flag is used, then '...' can be used to
26182618
elide substrings in the desired output:
2619-
>>> print range(1000) #doctest: +ELLIPSIS
2619+
>>> print(range(1000)) #doctest: +ELLIPSIS
26202620
[0, 1, 2, ..., 999]
26212621
""",
26222622

26232623
"whitespace normalization": r"""
26242624
If the whitespace normalization flag is used, then
26252625
differences in whitespace are ignored.
2626-
>>> print range(30) #doctest: +NORMALIZE_WHITESPACE
2626+
>>> print(range(30)) #doctest: +NORMALIZE_WHITESPACE
26272627
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
26282628
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
26292629
27, 28, 29]

Lib/nntplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
>>> from nntplib import NNTP
66
>>> s = NNTP('news')
77
>>> resp, count, first, last, name = s.group('comp.lang.python')
8-
>>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last
8+
>>> print('Group', name, 'has', count, 'articles, range', first, 'to', last)
99
Group comp.lang.python has 51 articles, range 5770 to 5821
1010
>>> resp, subs = s.xhdr('subject', first + '-' + last)
1111
>>> resp = s.quit()

Lib/smtplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
>>> import smtplib
1717
>>> s=smtplib.SMTP("localhost")
18-
>>> print s.help()
18+
>>> print(s.help())
1919
This is Sendmail version 8.8.4
2020
Topics:
2121
HELO EHLO MAIL RCPT DATA

Lib/telnetlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
>>> from telnetlib import Telnet
99
>>> tn = Telnet('www.python.org', 79) # connect to finger port
1010
>>> tn.write('guido\r\n')
11-
>>> print tn.read_all()
11+
>>> print(tn.read_all())
1212
Login Name TTY Idle When Where
1313
guido Guido van Rossum pts/2 <Dec 2 11:10> snag.cnri.reston..
1414

Lib/test/doctest_aliases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TwoNames:
55

66
def f(self):
77
'''
8-
>>> print TwoNames().f()
8+
>>> print(TwoNames().f())
99
f
1010
'''
1111
return 'f'

0 commit comments

Comments
 (0)