summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-02-09 20:13:25 (GMT)
committerGuido van Rossum <guido@python.org>2007-02-09 20:13:25 (GMT)
commit7131f84400d85d35d0323c262cc0926bef5a18cf (patch)
tree4cc23830260de4be99d1ba56b9b80b20edb02996
parent4502c804b9f15d26d7636d9c3b5f7faadb2f5362 (diff)
downloadcpython-7131f84400d85d35d0323c262cc0926bef5a18cf.zip
cpython-7131f84400d85d35d0323c262cc0926bef5a18cf.tar.gz
cpython-7131f84400d85d35d0323c262cc0926bef5a18cf.tar.bz2
Fix a bunch of doctests with the -d option of refactor.py.
We still have 27 failing tests (down from 39).
-rw-r--r--Lib/Cookie.py10
-rw-r--r--Lib/ctypes/test/test_objects.py6
-rw-r--r--Lib/decimal.py48
-rw-r--r--Lib/difflib.py16
-rw-r--r--Lib/distutils/versionpredicate.py2
-rw-r--r--Lib/doctest.py14
-rw-r--r--Lib/nntplib.py2
-rwxr-xr-xLib/smtplib.py2
-rw-r--r--Lib/telnetlib.py2
-rw-r--r--Lib/test/doctest_aliases.py2
-rw-r--r--Lib/test/sample_doctest.py6
-rw-r--r--Lib/test/test_code.py6
-rw-r--r--Lib/test/test_deque.py8
-rw-r--r--Lib/test/test_descrtut.py62
-rw-r--r--Lib/test/test_doctest.py86
-rw-r--r--Lib/test/test_doctest2.py26
-rw-r--r--Lib/test/test_generators.py78
-rw-r--r--Lib/test/test_genexps.py6
-rw-r--r--Lib/test/test_itertools.py20
-rw-r--r--Lib/test/test_syntax.py8
-rw-r--r--Lib/test/test_urllib2.py2
-rw-r--r--Lib/test/test_weakref.py8
-rw-r--r--Lib/test/test_xml_etree.py10
-rw-r--r--Lib/test/test_xml_etree_c.py4
24 files changed, 217 insertions, 217 deletions
diff --git a/Lib/Cookie.py b/Lib/Cookie.py
index fb06840..6c28e79 100644
--- a/Lib/Cookie.py
+++ b/Lib/Cookie.py
@@ -80,9 +80,9 @@ attributes by using the .output() function
>>> C = Cookie.SmartCookie()
>>> C["rocky"] = "road"
>>> C["rocky"]["path"] = "/cookie"
- >>> print(C.output(header="Cookie:"))
+ >>> print((C.output(header="Cookie:")))
Cookie: rocky=road; Path=/cookie
- >>> print(C.output(attrs=[], header="Cookie:"))
+ >>> print((C.output(attrs=[], header="Cookie:")))
Cookie: rocky=road
The load() method of a Cookie extracts cookies from a string. In a
@@ -100,7 +100,7 @@ such trickeries do not confuse it.
>>> C = Cookie.SmartCookie()
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
- >>> print(C)
+ >>> print((C))
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
Each element of the Cookie also supports all of the RFC 2109
@@ -110,7 +110,7 @@ attribute.
>>> C = Cookie.SmartCookie()
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
- >>> print(C)
+ >>> print((C))
Set-Cookie: oreo=doublestuff; Path=/
Each dictionary element has a 'value' attribute, which gives you
@@ -198,7 +198,7 @@ it is still possible to use Cookie.Cookie() to create a Cookie. In
fact, this simply returns a SmartCookie.
>>> C = Cookie.Cookie()
- >>> print(C.__class__.__name__)
+ >>> print((C.__class__.__name__))
SmartCookie
diff --git a/Lib/ctypes/test/test_objects.py b/Lib/ctypes/test/test_objects.py
index 4d921d2..500b009 100644
--- a/Lib/ctypes/test/test_objects.py
+++ b/Lib/ctypes/test/test_objects.py
@@ -13,7 +13,7 @@ Here is an array of string pointers:
>>> from ctypes import *
>>> array = (c_char_p * 5)()
->>> print array._objects
+>>> print(array._objects)
None
>>>
@@ -34,14 +34,14 @@ in a 'base' object.
... _fields_ = [("x", c_int), ("y", c_int), ("array", c_char_p * 5)]
...
>>> x = X()
->>> print x._objects
+>>> print(x._objects)
None
>>>
The'array' attribute of the 'x' object shares part of the memory buffer
of 'x' ('_b_base_' is either None, or the root object owning the memory block):
->>> print x.array._b_base_ # doctest: +ELLIPSIS
+>>> print(x.array._b_base_) # doctest: +ELLIPSIS
<ctypes.test.test_objects.X object at 0x...>
>>>
diff --git a/Lib/decimal.py b/Lib/decimal.py
index f70e374..198fd1a 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -56,31 +56,31 @@ Decimal("2.60")
>>> Decimal("12.34") + Decimal("3.87") - Decimal("18.41")
Decimal("-2.20")
>>> dig = Decimal(1)
->>> print dig / Decimal(3)
+>>> print(dig / Decimal(3))
0.333333333
>>> getcontext().prec = 18
->>> print dig / Decimal(3)
+>>> print(dig / Decimal(3))
0.333333333333333333
->>> print dig.sqrt()
+>>> print(dig.sqrt())
1
->>> print Decimal(3).sqrt()
+>>> print(Decimal(3).sqrt())
1.73205080756887729
->>> print Decimal(3) ** 123
+>>> print(Decimal(3) ** 123)
4.85192780976896427E+58
>>> inf = Decimal(1) / Decimal(0)
->>> print inf
+>>> print(inf)
Infinity
>>> neginf = Decimal(-1) / Decimal(0)
->>> print neginf
+>>> print(neginf)
-Infinity
->>> print neginf + inf
+>>> print(neginf + inf)
NaN
->>> print neginf * inf
+>>> print(neginf * inf)
-Infinity
->>> print dig / 0
+>>> print(dig / 0)
Infinity
>>> getcontext().traps[DivisionByZero] = 1
->>> print dig / 0
+>>> print(dig / 0)
Traceback (most recent call last):
...
...
@@ -88,29 +88,29 @@ Traceback (most recent call last):
decimal.DivisionByZero: x / 0
>>> c = Context()
>>> c.traps[InvalidOperation] = 0
->>> print c.flags[InvalidOperation]
+>>> print(c.flags[InvalidOperation])
0
>>> c.divide(Decimal(0), Decimal(0))
Decimal("NaN")
>>> c.traps[InvalidOperation] = 1
->>> print c.flags[InvalidOperation]
+>>> print(c.flags[InvalidOperation])
1
>>> c.flags[InvalidOperation] = 0
->>> print c.flags[InvalidOperation]
+>>> print(c.flags[InvalidOperation])
0
->>> print c.divide(Decimal(0), Decimal(0))
+>>> print(c.divide(Decimal(0), Decimal(0)))
Traceback (most recent call last):
...
...
...
decimal.InvalidOperation: 0 / 0
->>> print c.flags[InvalidOperation]
+>>> print(c.flags[InvalidOperation])
1
>>> c.flags[InvalidOperation] = 0
>>> c.traps[InvalidOperation] = 0
->>> print c.divide(Decimal(0), Decimal(0))
+>>> print(c.divide(Decimal(0), Decimal(0)))
NaN
->>> print c.flags[InvalidOperation]
+>>> print(c.flags[InvalidOperation])
1
>>>
"""
@@ -483,19 +483,19 @@ def localcontext(ctx=None):
# as the doctest module doesn't understand __future__ statements
"""
>>> from __future__ import with_statement
- >>> print getcontext().prec
+ >>> print(getcontext().prec)
28
>>> with localcontext():
... ctx = getcontext()
... ctx.prec() += 2
- ... print ctx.prec
- ...
+ ... print(ctx.prec)
+ ...
30
>>> with localcontext(ExtendedContext):
- ... print getcontext().prec
- ...
+ ... print(getcontext().prec)
+ ...
9
- >>> print getcontext().prec
+ >>> print(getcontext().prec)
28
"""
if ctx is None: ctx = getcontext()
diff --git a/Lib/difflib.py b/Lib/difflib.py
index f2d1343..c7b2679 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -76,7 +76,7 @@ class SequenceMatcher:
sequences. As a rule of thumb, a .ratio() value over 0.6 means the
sequences are close matches:
- >>> print(round(s.ratio(), 3))
+ >>> print((round(s.ratio(), 3)))
0.866
>>>
@@ -84,7 +84,7 @@ class SequenceMatcher:
.get_matching_blocks() is handy:
>>> for block in s.get_matching_blocks():
- ... print("a[%d] and b[%d] match for %d elements" % block)
+ ... print(("a[%d] and b[%d] match for %d elements" % block))
a[0] and b[0] match for 8 elements
a[8] and b[17] match for 21 elements
a[29] and b[38] match for 0 elements
@@ -97,7 +97,7 @@ class SequenceMatcher:
use .get_opcodes():
>>> for opcode in s.get_opcodes():
- ... print("%6s a[%d:%d] b[%d:%d]" % opcode)
+ ... print(("%6s a[%d:%d] b[%d:%d]" % opcode))
equal a[0:8] b[0:8]
insert a[8:8] b[8:17]
equal a[8:29] b[17:38]
@@ -545,8 +545,8 @@ class SequenceMatcher:
>>> b = "abycdf"
>>> s = SequenceMatcher(None, a, b)
>>> for tag, i1, i2, j1, j2 in s.get_opcodes():
- ... print(("%7s a[%d:%d] (%s) b[%d:%d] (%s)" %
- ... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])))
+ ... print((("%7s a[%d:%d] (%s) b[%d:%d] (%s)" %
+ ... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2]))))
delete a[0:1] (q) b[0:0] ()
equal a[1:3] (ab) b[0:2] (ab)
replace a[3:4] (x) b[2:3] (y)
@@ -1059,8 +1059,8 @@ class Differ:
>>> d = Differ()
>>> results = d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n',
... ' ^ ^ ^ ', '+ ^ ^ ^ ')
- >>> for line in results: print(repr(line))
- ...
+ >>> for line in results: print((repr(line)))
+ ...
'- \tabcDefghiJkl\n'
'? \t ^ ^ ^\n'
'+ \t\tabcdefGhijkl\n'
@@ -1165,7 +1165,7 @@ def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
... 'zero one tree four'.split(), 'Original', 'Current',
... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:20:52 2003',
... lineterm=''):
- ... print(line)
+ ... print((line))
--- Original Sat Jan 26 23:30:50 1991
+++ Current Fri Jun 06 10:20:52 2003
@@ -1,4 +1,4 @@
diff --git a/Lib/distutils/versionpredicate.py b/Lib/distutils/versionpredicate.py
index ba8b6c0..434b34f 100644
--- a/Lib/distutils/versionpredicate.py
+++ b/Lib/distutils/versionpredicate.py
@@ -40,7 +40,7 @@ class VersionPredicate:
The str() of a `VersionPredicate` provides a normalized
human-readable version of the expression::
- >>> print v
+ >>> print(v)
pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3)
The `satisfied_by()` method can be used to determine with a given
diff --git a/Lib/doctest.py b/Lib/doctest.py
index f55396e..210e845 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -1012,7 +1012,7 @@ class DocTestRunner:
>>> runner = DocTestRunner(verbose=False)
>>> tests.sort(key = lambda test: test.name)
>>> for test in tests:
- ... print test.name, '->', runner.run(test)
+ ... print(test.name, '->', runner.run(test))
_TestClass -> (0, 2)
_TestClass.__init__ -> (0, 2)
_TestClass.get -> (0, 2)
@@ -2419,7 +2419,7 @@ def script_from_examples(s):
... Ho hum
... '''
- >>> print script_from_examples(text)
+ >>> print(script_from_examples(text))
# Here are examples of simple math.
#
# Python has super accurate integer addition
@@ -2554,7 +2554,7 @@ class _TestClass:
"""val -> _TestClass object with associated value val.
>>> t = _TestClass(123)
- >>> print t.get()
+ >>> print(t.get())
123
"""
@@ -2574,7 +2574,7 @@ class _TestClass:
"""get() -> return TestClass's associated value.
>>> x = _TestClass(-42)
- >>> print x.get()
+ >>> print(x.get())
-42
"""
@@ -2606,7 +2606,7 @@ __test__ = {"_TestClass": _TestClass,
"blank lines": r"""
Blank lines can be marked with <BLANKLINE>:
- >>> print 'foo\n\nbar\n'
+ >>> print('foo\n\nbar\n')
foo
<BLANKLINE>
bar
@@ -2616,14 +2616,14 @@ __test__ = {"_TestClass": _TestClass,
"ellipsis": r"""
If the ellipsis flag is used, then '...' can be used to
elide substrings in the desired output:
- >>> print range(1000) #doctest: +ELLIPSIS
+ >>> print(range(1000)) #doctest: +ELLIPSIS
[0, 1, 2, ..., 999]
""",
"whitespace normalization": r"""
If the whitespace normalization flag is used, then
differences in whitespace are ignored.
- >>> print range(30) #doctest: +NORMALIZE_WHITESPACE
+ >>> print(range(30)) #doctest: +NORMALIZE_WHITESPACE
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29]
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index 3f933f9..320653f 100644
--- a/Lib/nntplib.py
+++ b/Lib/nntplib.py
@@ -5,7 +5,7 @@ Example:
>>> from nntplib import NNTP
>>> s = NNTP('news')
>>> resp, count, first, last, name = s.group('comp.lang.python')
->>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last
+>>> print('Group', name, 'has', count, 'articles, range', first, 'to', last)
Group comp.lang.python has 51 articles, range 5770 to 5821
>>> resp, subs = s.xhdr('subject', first + '-' + last)
>>> resp = s.quit()
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index aedcac4..9851d08 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -15,7 +15,7 @@ Example:
>>> import smtplib
>>> s=smtplib.SMTP("localhost")
- >>> print s.help()
+ >>> print(s.help())
This is Sendmail version 8.8.4
Topics:
HELO EHLO MAIL RCPT DATA
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py
index f482abf..dd263ae 100644
--- a/Lib/telnetlib.py
+++ b/Lib/telnetlib.py
@@ -8,7 +8,7 @@ Example:
>>> from telnetlib import Telnet
>>> tn = Telnet('www.python.org', 79) # connect to finger port
>>> tn.write('guido\r\n')
->>> print tn.read_all()
+>>> print(tn.read_all())
Login Name TTY Idle When Where
guido Guido van Rossum pts/2 <Dec 2 11:10> snag.cnri.reston..
diff --git a/Lib/test/doctest_aliases.py b/Lib/test/doctest_aliases.py
index e6e5ca9..e5e6b29 100644
--- a/Lib/test/doctest_aliases.py
+++ b/Lib/test/doctest_aliases.py
@@ -5,7 +5,7 @@ class TwoNames:
def f(self):
'''
- >>> print TwoNames().f()
+ >>> print(TwoNames().f())
f
'''
return 'f'
diff --git a/Lib/test/sample_doctest.py b/Lib/test/sample_doctest.py
index e5adee0..89eb5cb 100644
--- a/Lib/test/sample_doctest.py
+++ b/Lib/test/sample_doctest.py
@@ -40,9 +40,9 @@ def test_silly_setup():
def w_blank():
"""
>>> if 1:
- ... print 'a'
- ... print
- ... print 'b'
+ ... print('a')
+ ... print()
+ ... print('b')
a
<BLANKLINE>
b
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index 13ec254..f7014a6 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -50,9 +50,9 @@ flags: 67
consts: ('None',)
>>> def attrs(obj):
-... print obj.attr1
-... print obj.attr2
-... print obj.attr3
+... print(obj.attr1)
+... print(obj.attr2)
+... print(obj.attr3)
>>> dump(attrs.func_code)
name: attrs
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index 9f7caec..9bb1472 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -504,7 +504,7 @@ Example from the Library Reference: Doc/lib/libcollections.tex
>>> from collections import deque
>>> d = deque('ghi') # make a new deque with three items
>>> for elem in d: # iterate over the deque's elements
-... print elem.upper()
+... print(elem.upper())
G
H
I
@@ -574,8 +574,8 @@ deque(['a', 'b', 'd', 'e', 'f'])
...
>>> for value in roundrobin('abc', 'd', 'efgh'):
-... print value
-...
+... print(value)
+...
a
d
e
@@ -593,7 +593,7 @@ h
... d.append(pair)
... return list(d)
...
->>> print maketree('abcdefgh')
+>>> print(maketree('abcdefgh'))
[[[['a', 'b'], ['c', 'd']], [['e', 'f'], ['g', 'h']]]]
"""
diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py
index aca6660..3351b67 100644
--- a/Lib/test/test_descrtut.py
+++ b/Lib/test/test_descrtut.py
@@ -36,28 +36,28 @@ test_1 = """
Here's the new type at work:
- >>> print defaultdict # show our type
+ >>> print(defaultdict) # show our type
<class 'test.test_descrtut.defaultdict'>
- >>> print type(defaultdict) # its metatype
+ >>> print(type(defaultdict)) # its metatype
<type 'type'>
>>> a = defaultdict(default=0.0) # create an instance
- >>> print a # show the instance
+ >>> print(a) # show the instance
{}
- >>> print type(a) # show its type
+ >>> print(type(a)) # show its type
<class 'test.test_descrtut.defaultdict'>
- >>> print a.__class__ # show its class
+ >>> print(a.__class__) # show its class
<class 'test.test_descrtut.defaultdict'>
- >>> print type(a) is a.__class__ # its type is its class
+ >>> print(type(a) is a.__class__) # its type is its class
True
>>> a[1] = 3.25 # modify the instance
- >>> print a # show the new value
+ >>> print(a) # show the new value
{1: 3.25}
- >>> print a[1] # show the new item
+ >>> print(a[1]) # show the new item
3.25
- >>> print a[0] # a non-existant item
+ >>> print(a[0]) # a non-existant item
0.0
>>> a.merge({1:100, 2:200}) # use a dict method
- >>> print sortdict(a) # show the result
+ >>> print(sortdict(a)) # show the result
{1: 3.25, 2: 200}
>>>
@@ -65,13 +65,13 @@ We can also use the new type in contexts where classic only allows "real"
dictionaries, such as the locals/globals dictionaries for the exec
statement or the built-in function eval():
- >>> print sorted(a.keys())
+ >>> print(sorted(a.keys()))
[1, 2]
>>> exec("x = 3; print x", a)
3
- >>> print sorted(a.keys(), key=lambda x: (str(type(x)), x))
+ >>> print(sorted(a.keys(), key=lambda x: (str(type(x)), x)))
[1, 2, '__builtins__', 'x']
- >>> print a['x']
+ >>> print(a['x'])
3
>>>
@@ -79,21 +79,21 @@ Now I'll show that defaultdict instances have dynamic instance variables,
just like classic classes:
>>> a.default = -1
- >>> print a["noway"]
+ >>> print(a["noway"])
-1
>>> a.default = -1000
- >>> print a["noway"]
+ >>> print(a["noway"])
-1000
>>> 'default' in dir(a)
True
>>> a.x1 = 100
>>> a.x2 = 200
- >>> print a.x1
+ >>> print(a.x1)
100
>>> d = dir(a)
>>> 'default' in d and 'x1' in d and 'x2' in d
True
- >>> print sortdict(a.__dict__)
+ >>> print(sortdict(a.__dict__))
{'default': -1000, 'x1': 100, 'x2': 200}
>>>
"""
@@ -242,10 +242,10 @@ methods. Static methods are easy to describe: they behave pretty much like
static methods in C++ or Java. Here's an example:
>>> class C:
- ...
+ ...
... @staticmethod
... def foo(x, y):
- ... print "staticmethod", x, y
+ ... print("staticmethod", x, y)
>>> C.foo(1, 2)
staticmethod 1 2
@@ -259,7 +259,7 @@ implicit first argument that is the *class* for which they are invoked.
>>> class C:
... @classmethod
... def foo(cls, y):
- ... print "classmethod", cls, y
+ ... print("classmethod", cls, y)
>>> C.foo(1)
classmethod <class 'test.test_descrtut.C'> 1
@@ -285,7 +285,7 @@ But notice this:
>>> class E(C):
... @classmethod
... def foo(cls, y): # override C.foo
- ... print "E.foo() called"
+ ... print("E.foo() called")
... C.foo(y)
>>> E.foo(1)
@@ -343,10 +343,10 @@ Here's a small demonstration:
>>> a = C()
>>> a.x = 10
- >>> print a.x
+ >>> print(a.x)
10
>>> a.x = -10
- >>> print a.x
+ >>> print(a.x)
0
>>>
@@ -369,10 +369,10 @@ Hmm -- property is builtin now, so let's try it that way too.
>>> a = C()
>>> a.x = 10
- >>> print a.x
+ >>> print(a.x)
10
>>> a.x = -10
- >>> print a.x
+ >>> print(a.x)
0
>>>
"""
@@ -385,12 +385,12 @@ This example is implicit in the writeup.
>>> class A: # implicit new-style class
... def save(self):
-... print "called A.save()"
+... print("called A.save()")
>>> class B(A):
... pass
>>> class C(A):
... def save(self):
-... print "called C.save()"
+... print("called C.save()")
>>> class D(B, C):
... pass
@@ -399,12 +399,12 @@ called C.save()
>>> class A(object): # explicit new-style class
... def save(self):
-... print "called A.save()"
+... print("called A.save()")
>>> class B(A):
... pass
>>> class C(A):
... def save(self):
-... print "called C.save()"
+... print("called C.save()")
>>> class D(B, C):
... pass
@@ -433,7 +433,7 @@ test_7 = """
Cooperative methods and "super"
->>> print D().m() # "DCBA"
+>>> print(D().m()) # "DCBA"
DCBA
"""
@@ -443,7 +443,7 @@ Backwards incompatibilities
>>> class A:
... def foo(self):
-... print "called A.foo()"
+... print("called A.foo()")
>>> class B(A):
... pass
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index ac9d00d..e7f84ae 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -14,7 +14,7 @@ def sample_func(v):
"""
Blah blah
- >>> print sample_func(22)
+ >>> print(sample_func(22))
44
Yee ha!
@@ -23,7 +23,7 @@ def sample_func(v):
class SampleClass:
"""
- >>> print 1
+ >>> print(1)
1
>>> # comments get ignored. so are empty PS1 and PS2 prompts:
@@ -34,33 +34,33 @@ class SampleClass:
>>> sc = SampleClass(3)
>>> for i in range(10):
... sc = sc.double()
- ... print sc.get(),
+ ... print(sc.get(), end=' ')
6 12 24 48 96 192 384 768 1536 3072
"""
def __init__(self, val):
"""
- >>> print SampleClass(12).get()
+ >>> print(SampleClass(12).get())
12
"""
self.val = val
def double(self):
"""
- >>> print SampleClass(12).double().get()
+ >>> print(SampleClass(12).double().get())
24
"""
return SampleClass(self.val + self.val)
def get(self):
"""
- >>> print SampleClass(-5).get()
+ >>> print(SampleClass(-5).get())
-5
"""
return self.val
def a_staticmethod(v):
"""
- >>> print SampleClass.a_staticmethod(10)
+ >>> print(SampleClass.a_staticmethod(10))
11
"""
return v+1
@@ -68,16 +68,16 @@ class SampleClass:
def a_classmethod(cls, v):
"""
- >>> print SampleClass.a_classmethod(10)
+ >>> print(SampleClass.a_classmethod(10))
12
- >>> print SampleClass(0).a_classmethod(10)
+ >>> print(SampleClass(0).a_classmethod(10))
12
"""
return v+2
a_classmethod = classmethod(a_classmethod)
a_property = property(get, doc="""
- >>> print SampleClass(22).a_property
+ >>> print(SampleClass(22).a_property)
22
""")
@@ -85,12 +85,12 @@ class SampleClass:
"""
>>> x = SampleClass.NestedClass(5)
>>> y = x.square()
- >>> print y.get()
+ >>> print(y.get())
25
"""
def __init__(self, val=0):
"""
- >>> print SampleClass.NestedClass().get()
+ >>> print(SampleClass.NestedClass().get())
0
"""
self.val = val
@@ -101,28 +101,28 @@ class SampleClass:
class SampleNewStyleClass(object):
r"""
- >>> print '1\n2\n3'
+ >>> print('1\n2\n3')
1
2
3
"""
def __init__(self, val):
"""
- >>> print SampleNewStyleClass(12).get()
+ >>> print(SampleNewStyleClass(12).get())
12
"""
self.val = val
def double(self):
"""
- >>> print SampleNewStyleClass(12).double().get()
+ >>> print(SampleNewStyleClass(12).double().get())
24
"""
return SampleNewStyleClass(self.val + self.val)
def get(self):
"""
- >>> print SampleNewStyleClass(-5).get()
+ >>> print(SampleNewStyleClass(-5).get())
-5
"""
return self.val
@@ -278,7 +278,7 @@ constructor:
>>> parser = doctest.DocTestParser()
>>> test = parser.get_doctest(docstring, globs, 'some_test',
... 'some_file', 20)
- >>> print test
+ >>> print(test)
<DocTest some_test from some_file:20 (2 examples)>
>>> len(test.examples)
2
@@ -368,7 +368,7 @@ We'll simulate a __file__ attr that ends in pyc:
>>> tests = finder.find(sample_func)
- >>> print tests # doctest: +ELLIPSIS
+ >>> print(tests) # doctest: +ELLIPSIS
[<DocTest sample_func from ...:13 (1 example)>]
The exact name depends on how test_doctest was invoked, so allow for
@@ -420,7 +420,7 @@ methods, classmethods, staticmethods, properties, and nested classes.
>>> finder = doctest.DocTestFinder()
>>> tests = finder.find(SampleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
3 SampleClass
3 SampleClass.NestedClass
1 SampleClass.NestedClass.__init__
@@ -435,7 +435,7 @@ New-style classes are also supported:
>>> tests = finder.find(SampleNewStyleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
1 SampleNewStyleClass
1 SampleNewStyleClass.__init__
1 SampleNewStyleClass.double
@@ -474,7 +474,7 @@ functions, classes, and the `__test__` dictionary, if it exists:
>>> import test.test_doctest
>>> tests = finder.find(m, module=test.test_doctest)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
1 some_module
3 some_module.SampleClass
3 some_module.SampleClass.NestedClass
@@ -496,9 +496,9 @@ will only be generated for it once:
>>> from test import doctest_aliases
>>> tests = excl_empty_finder.find(doctest_aliases)
- >>> print len(tests)
+ >>> print(len(tests))
2
- >>> print tests[0].name
+ >>> print(tests[0].name)
test.doctest_aliases.TwoNames
TwoNames.f and TwoNames.g are bound to the same object.
@@ -514,7 +514,7 @@ By default, an object with no doctests doesn't create any tests:
>>> tests = doctest.DocTestFinder().find(SampleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
3 SampleClass
3 SampleClass.NestedClass
1 SampleClass.NestedClass.__init__
@@ -532,7 +532,7 @@ displays.
>>> tests = doctest.DocTestFinder(exclude_empty=False).find(SampleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
3 SampleClass
3 SampleClass.NestedClass
1 SampleClass.NestedClass.__init__
@@ -552,7 +552,7 @@ using the `recurse` flag:
>>> tests = doctest.DocTestFinder(recurse=False).find(SampleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
3 SampleClass
Line numbers
@@ -603,9 +603,9 @@ text:
>>> parser = doctest.DocTestParser()
>>> for piece in parser.parse(s):
... if isinstance(piece, doctest.Example):
- ... print 'Example:', (piece.source, piece.want, piece.lineno)
+ ... print('Example:', (piece.source, piece.want, piece.lineno))
... else:
- ... print ' Text:', repr(piece)
+ ... print(' Text:', repr(piece))
Text: '\n'
Example: ('x, y = 2, 3 # no output expected\n', '', 1)
Text: ''
@@ -617,7 +617,7 @@ text:
The `get_examples` method returns just the examples:
>>> for piece in parser.get_examples(s):
- ... print (piece.source, piece.want, piece.lineno)
+ ... print((piece.source, piece.want, piece.lineno))
('x, y = 2, 3 # no output expected\n', '', 1)
('if 1:\n print x\n print y\n', '2\n3\n', 2)
('x+y\n', '5\n', 9)
@@ -629,7 +629,7 @@ given arguments:
>>> (test.name, test.filename, test.lineno)
('name', 'filename', 5)
>>> for piece in test.examples:
- ... print (piece.source, piece.want, piece.lineno)
+ ... print((piece.source, piece.want, piece.lineno))
('x, y = 2, 3 # no output expected\n', '', 1)
('if 1:\n print x\n print y\n', '2\n3\n', 2)
('x+y\n', '5\n', 9)
@@ -996,7 +996,7 @@ treated as equal:
(0, 1)
An example from the docs:
- >>> print range(20) #doctest: +NORMALIZE_WHITESPACE
+ >>> print(range(20)) #doctest: +NORMALIZE_WHITESPACE
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
@@ -1029,21 +1029,21 @@ output to match any substring in the actual output:
... also matches nothing:
>>> for i in range(100):
- ... print i**2, #doctest: +ELLIPSIS
+ ... print(i**2, end=' ') #doctest: +ELLIPSIS
0 1...4...9 16 ... 36 49 64 ... 9801
... can be surprising; e.g., this test passes:
>>> for i in range(21): #doctest: +ELLIPSIS
- ... print i,
+ ... print(i, end=' ')
0 1 2 ...1...2...0
Examples from the docs:
- >>> print range(20) # doctest:+ELLIPSIS
+ >>> print(range(20)) # doctest:+ELLIPSIS
[0, 1, ..., 18, 19]
- >>> print range(20) # doctest: +ELLIPSIS
+ >>> print(range(20)) # doctest: +ELLIPSIS
... # doctest: +NORMALIZE_WHITESPACE
[0, 1, ..., 18, 19]
@@ -1063,7 +1063,7 @@ which would be unavailable.) The SKIP flag can also be used for
UncheckedBlowUpError: Nobody checks me.
>>> import random
- >>> print random.random() # doctest: +SKIP
+ >>> print(random.random()) # doctest: +SKIP
0.721216923889
The REPORT_UDIFF flag causes failures that involve multi-line expected
@@ -1516,7 +1516,7 @@ words and expected output are converted to comments:
>>> import test.test_doctest
>>> name = 'test.test_doctest.sample_func'
- >>> print doctest.testsource(test.test_doctest, name)
+ >>> print(doctest.testsource(test.test_doctest, name))
# Blah blah
#
print sample_func(22)
@@ -1527,7 +1527,7 @@ words and expected output are converted to comments:
<BLANKLINE>
>>> name = 'test.test_doctest.SampleNewStyleClass'
- >>> print doctest.testsource(test.test_doctest, name)
+ >>> print(doctest.testsource(test.test_doctest, name))
print '1\n2\n3'
# Expected:
## 1
@@ -1536,7 +1536,7 @@ words and expected output are converted to comments:
<BLANKLINE>
>>> name = 'test.test_doctest.SampleClass.a_classmethod'
- >>> print doctest.testsource(test.test_doctest, name)
+ >>> print(doctest.testsource(test.test_doctest, name))
print SampleClass.a_classmethod(10)
# Expected:
## 12
@@ -2037,7 +2037,7 @@ def test_trailing_space_in_test():
Trailing spaces in expected output are significant:
>>> x, y = 'foo', ''
- >>> print x, y
+ >>> print(x, y)
foo \n
"""
@@ -2054,7 +2054,7 @@ def test_unittest_reportflags():
... optionflags=doctest.DONT_ACCEPT_BLANKLINE)
>>> import unittest
>>> result = suite.run(unittest.TestResult())
- >>> print result.failures[0][1] # doctest: +ELLIPSIS
+ >>> print(result.failures[0][1]) # doctest: +ELLIPSIS
Traceback ...
Failed example:
favorite_color
@@ -2071,7 +2071,7 @@ def test_unittest_reportflags():
Now, when we run the test:
>>> result = suite.run(unittest.TestResult())
- >>> print result.failures[0][1] # doctest: +ELLIPSIS
+ >>> print(result.failures[0][1]) # doctest: +ELLIPSIS
Traceback ...
Failed example:
favorite_color
@@ -2092,7 +2092,7 @@ def test_unittest_reportflags():
Then the default eporting options are ignored:
>>> result = suite.run(unittest.TestResult())
- >>> print result.failures[0][1] # doctest: +ELLIPSIS
+ >>> print(result.failures[0][1]) # doctest: +ELLIPSIS
Traceback ...
Failed example:
favorite_color
diff --git a/Lib/test/test_doctest2.py b/Lib/test/test_doctest2.py
index 865a32e..a7d548c 100644
--- a/Lib/test/test_doctest2.py
+++ b/Lib/test/test_doctest2.py
@@ -2,7 +2,7 @@
u"""A module to test whether doctest recognizes some 2.2 features,
like static and class methods.
->>> print 'yup' # 1
+>>> print('yup') # 1
yup
We include some (random) encoded (utf-8) text in the text surrounding
@@ -17,7 +17,7 @@ from test import test_support
class C(object):
u"""Class C.
- >>> print C() # 2
+ >>> print(C()) # 2
42
@@ -31,13 +31,13 @@ class C(object):
def __init__(self):
"""C.__init__.
- >>> print C() # 3
+ >>> print(C()) # 3
42
"""
def __str__(self):
"""
- >>> print C() # 4
+ >>> print(C()) # 4
42
"""
return "42"
@@ -45,13 +45,13 @@ class C(object):
class D(object):
"""A nested D class.
- >>> print "In D!" # 5
+ >>> print("In D!") # 5
In D!
"""
def nested(self):
"""
- >>> print 3 # 6
+ >>> print(3) # 6
3
"""
@@ -59,7 +59,7 @@ class C(object):
"""
>>> c = C() # 7
>>> c.x = 12 # 8
- >>> print c.x # 9
+ >>> print(c.x) # 9
-12
"""
return -self._x
@@ -68,7 +68,7 @@ class C(object):
"""
>>> c = C() # 10
>>> c.x = 12 # 11
- >>> print c.x # 12
+ >>> print(c.x) # 12
-12
"""
self._x = value
@@ -76,7 +76,7 @@ class C(object):
x = property(getx, setx, doc="""\
>>> c = C() # 13
>>> c.x = 12 # 14
- >>> print c.x # 15
+ >>> print(c.x) # 15
-12
""")
@@ -85,9 +85,9 @@ class C(object):
"""
A static method.
- >>> print C.statm() # 16
+ >>> print(C.statm()) # 16
666
- >>> print C().statm() # 17
+ >>> print(C().statm()) # 17
666
"""
return 666
@@ -97,9 +97,9 @@ class C(object):
"""
A class method.
- >>> print C.clsm(22) # 18
+ >>> print(C.clsm(22)) # 18
22
- >>> print C().clsm(23) # 19
+ >>> print(C().clsm(23)) # 19
23
"""
return val
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 39d016c..966ce32 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -6,7 +6,7 @@ Let's try a simple generator:
... yield 2
>>> for i in f():
- ... print i
+ ... print(i)
1
2
>>> g = f()
@@ -78,7 +78,7 @@ However, they are not exactly equivalent:
... raise StopIteration
... except:
... yield 42
- >>> print list(g2())
+ >>> print(list(g2()))
[42]
This may be surprising at first:
@@ -105,14 +105,14 @@ Generators always return to the most recent caller:
>>> def creator():
... r = yrange(5)
- ... print "creator", r.next()
+ ... print("creator", r.next())
... return r
- ...
+ ...
>>> def caller():
... r = creator()
... for i in r:
- ... print "caller", i
- ...
+ ... print("caller", i)
+ ...
>>> caller()
creator 0
caller 1
@@ -161,7 +161,7 @@ Specification: Return
... return
... except:
... yield 1
- >>> print list(f1())
+ >>> print(list(f1()))
[]
because, as in any function, return simply exits, but
@@ -171,7 +171,7 @@ Specification: Return
... raise StopIteration
... except:
... yield 42
- >>> print list(f2())
+ >>> print(list(f2()))
[42]
because StopIteration is captured by a bare "except", as is any
@@ -221,7 +221,7 @@ Specification: Try/Except/Finally
... finally:
... yield 10
... yield 11
- >>> print list(f())
+ >>> print(list(f()))
[1, 2, 4, 5, 8, 9, 10, 11]
>>>
@@ -270,7 +270,7 @@ Guido's binary tree example.
>>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
>>> # Print the nodes of the tree in in-order.
>>> for x in t:
- ... print x,
+ ... print(x, end=' ')
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
>>> # A non-recursive generator.
@@ -291,7 +291,7 @@ Guido's binary tree example.
>>> # Exercise the non-recursive generator.
>>> for x in t:
- ... print x,
+ ... print(x, end=' ')
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
"""
@@ -345,9 +345,9 @@ Next one was posted to c.l.py.
>>> seq = range(1, 5)
>>> for k in range(len(seq) + 2):
-... print "%d-combs of %s:" % (k, seq)
+... print("%d-combs of %s:" % (k, seq))
... for c in gcomb(seq, k):
-... print " ", c
+... print(" ", c)
0-combs of [1, 2, 3, 4]:
[]
1-combs of [1, 2, 3, 4]:
@@ -383,7 +383,7 @@ From the Iterators list, about the types of these things.
<type 'generator'>
>>> [s for s in dir(i) if not s.startswith('_')]
['close', 'gi_frame', 'gi_running', 'next', 'send', 'throw']
->>> print i.next.__doc__
+>>> print(i.next.__doc__)
x.next() -> the next value, or raise StopIteration
>>> iter(i) is i
True
@@ -447,14 +447,14 @@ Subject: Re: PEP 255: Simple Generators
>>> gen = random.WichmannHill(42)
>>> while 1:
... for s in sets:
-... print "%s->%s" % (s, s.find()),
-... print
+... print("%s->%s" % (s, s.find()), end=' ')
+... print()
... if len(roots) > 1:
... s1 = gen.choice(roots)
... roots.remove(s1)
... s2 = gen.choice(roots)
... s1.union(s2)
-... print "merged", s1, "into", s2
+... print("merged", s1, "into", s2)
... else:
... break
A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M
@@ -576,7 +576,7 @@ address space, and it *looked* like a very slow leak.
>>> result = m235()
>>> for i in range(3):
-... print firstn(result, 15)
+... print(firstn(result, 15))
[1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24]
[25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80]
[81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192]
@@ -613,7 +613,7 @@ efficient.
>>> m235 = LazyList(m235())
>>> for i in range(5):
-... print [m235[j] for j in range(15*i, 15*(i+1))]
+... print([m235[j] for j in range(15*i, 15*(i+1))])
[1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24]
[25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80]
[81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192]
@@ -684,7 +684,7 @@ m235 to share a single generator".
>>> it = m235()
>>> for i in range(5):
-... print firstn(it, 15)
+... print(firstn(it, 15))
[1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24]
[25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80]
[81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192]
@@ -890,13 +890,13 @@ This one caused a crash (see SF bug 567538):
... yield i
...
>>> g = f()
->>> print g.next()
+>>> print(g.next())
0
->>> print g.next()
+>>> print(g.next())
1
->>> print g.next()
+>>> print(g.next())
2
->>> print g.next()
+>>> print(g.next())
Traceback (most recent call last):
StopIteration
"""
@@ -1291,7 +1291,7 @@ Generate the 3-bit binary numbers in order. This illustrates dumbest-
possible use of conjoin, just to generate the full cross-product.
>>> for c in conjoin([lambda: iter((0, 1))] * 3):
-... print c
+... print(c)
[0, 0, 0]
[0, 0, 1]
[0, 1, 0]
@@ -1311,7 +1311,7 @@ generated sequence, you need to copy its results.
>>> for n in range(10):
... all = list(gencopy(conjoin([lambda: iter((0, 1))] * n)))
-... print n, len(all), all[0] == [0] * n, all[-1] == [1] * n
+... print(n, len(all), all[0] == [0] * n, all[-1] == [1] * n)
0 1 True True
1 2 True True
2 4 True True
@@ -1331,7 +1331,7 @@ And run an 8-queens solver.
>>> for row2col in q.solve():
... count += 1
... if count <= LIMIT:
-... print "Solution", count
+... print("Solution", count)
... q.printsolution(row2col)
Solution 1
+-+-+-+-+-+-+-+-+
@@ -1370,7 +1370,7 @@ Solution 2
| | | | |Q| | | |
+-+-+-+-+-+-+-+-+
->>> print count, "solutions in all."
+>>> print(count, "solutions in all.")
92 solutions in all.
And run a Knight's Tour on a 10x10 board. Note that there are about
@@ -1382,7 +1382,7 @@ And run a Knight's Tour on a 10x10 board. Note that there are about
>>> for x in k.solve():
... count += 1
... if count <= LIMIT:
-... print "Solution", count
+... print("Solution", count)
... k.printsolution(x)
... else:
... break
@@ -1460,7 +1460,7 @@ coroutine_tests = """\
Sending a value into a started generator:
>>> def f():
-... print (yield 1)
+... print((yield 1))
... yield 2
>>> g = f()
>>> g.next()
@@ -1507,16 +1507,16 @@ A yield expression with augmented assignment.
>>> seq = []
>>> c = coroutine(seq)
>>> c.next()
->>> print seq
+>>> print(seq)
[]
>>> c.send(10)
->>> print seq
+>>> print(seq)
[10]
>>> c.send(10)
->>> print seq
+>>> print(seq)
[10, 20]
>>> c.send(10)
->>> print seq
+>>> print(seq)
[10, 20, 30]
@@ -1553,9 +1553,9 @@ Now check some throw() conditions:
>>> def f():
... while True:
... try:
-... print (yield)
+... print((yield))
... except ValueError as v:
-... print "caught ValueError (%s)" % (v),
+... print("caught ValueError (%s)" % (v), end=' ')
>>> import sys
>>> g = f()
>>> g.next()
@@ -1616,7 +1616,7 @@ Traceback (most recent call last):
...
TypeError
->>> print g.gi_frame
+>>> print(g.gi_frame)
None
>>> g.send(2)
@@ -1639,7 +1639,7 @@ Now let's try closing a generator:
>>> def f():
... try: yield
... except GeneratorExit:
-... print "exiting"
+... print("exiting")
>>> g = f()
>>> g.next()
@@ -1660,7 +1660,7 @@ And finalization:
>>> def f():
... try: yield
... finally:
-... print "exiting"
+... print("exiting")
>>> g = f()
>>> g.next()
diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py
index 5fd9c7b..1b24672 100644
--- a/Lib/test/test_genexps.py
+++ b/Lib/test/test_genexps.py
@@ -157,12 +157,12 @@ Generators always return to the most recent caller:
>>> def creator():
... r = yrange(5)
- ... print "creator", r.next()
+ ... print("creator", r.next())
... return r
>>> def caller():
... r = creator()
... for i in r:
- ... print "caller", i
+ ... print("caller", i)
>>> caller()
creator 0
caller 1
@@ -221,7 +221,7 @@ Check that generator attributes are present
>>> set(attr for attr in dir(g) if not attr.startswith('__')) >= expected
True
- >>> print g.next.__doc__
+ >>> print(g.next.__doc__)
x.next() -> the next value, or raise StopIteration
>>> import types
>>> isinstance(g, types.GeneratorType)
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 5a1d4a1..a083e7c 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -764,24 +764,24 @@ libreftest = """ Doctest for examples in the library reference: libitertools.tex
>>> amounts = [120.15, 764.05, 823.14]
>>> for checknum, amount in izip(count(1200), amounts):
-... print 'Check %d is for $%.2f' % (checknum, amount)
-...
+... print('Check %d is for $%.2f' % (checknum, amount))
+...
Check 1200 is for $120.15
Check 1201 is for $764.05
Check 1202 is for $823.14
>>> import operator
>>> for cube in imap(operator.pow, xrange(1,4), repeat(3)):
-... print cube
-...
+... print(cube)
+...
1
8
27
>>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura', '', 'martin', '', 'walter', '', 'samuele']
>>> for name in islice(reportlines, 3, None, 2):
-... print name.title()
-...
+... print(name.title())
+...
Alex
Laura
Martin
@@ -792,8 +792,8 @@ Samuele
>>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
>>> di = sorted(sorted(d.iteritems()), key=itemgetter(1))
>>> for k, g in groupby(di, itemgetter(1)):
-... print k, map(itemgetter(0), g)
-...
+... print(k, map(itemgetter(0), g))
+...
1 ['a', 'c', 'e']
2 ['b', 'd', 'f']
3 ['g']
@@ -803,8 +803,8 @@ Samuele
# same group.
>>> data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
>>> for k, g in groupby(enumerate(data), lambda (i,x):i-x):
-... print map(operator.itemgetter(1), g)
-...
+... print(map(operator.itemgetter(1), g))
+...
[1]
[4, 5, 6]
[10]
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 2c7315d..ba33761 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -247,7 +247,7 @@ continue in for loop under finally shouuld be ok.
... finally:
... for abc in range(10):
... continue
- ... print abc
+ ... print(abc)
>>> test()
9
@@ -328,11 +328,11 @@ so we need to be sure that a break is actually inside a loop. If it
isn't, there should be a syntax error.
>>> try:
- ... print 1
+ ... print(1)
... break
- ... print 2
+ ... print(2)
... finally:
- ... print 3
+ ... print(3)
Traceback (most recent call last):
...
SyntaxError: 'break' outside loop (<doctest test.test_syntax[42]>, line 3)
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index be7d0c8..0ea606f 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -101,7 +101,7 @@ def test_request_headers_methods():
>>> r.has_header("Not-there")
False
- >>> print r.get_header("Not-there")
+ >>> print(r.get_header("Not-there"))
None
>>> r.get_header("Not-there", "default")
'default'
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index f81d168..76169f7 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -1072,7 +1072,7 @@ libreftest = """ Doctest for examples in the library reference: libweakref.tex
...
>>> obj = Dict(red=1, green=2, blue=3) # this object is weak referencable
>>> r = weakref.ref(obj)
->>> print r() is obj
+>>> print(r() is obj)
True
>>> import weakref
@@ -1085,7 +1085,7 @@ True
>>> o is o2
True
>>> del o, o2
->>> print r()
+>>> print(r())
None
>>> import weakref
@@ -1140,9 +1140,9 @@ True
>>> try:
... id2obj(a_id)
... except KeyError:
-... print 'OK'
+... print('OK')
... else:
-... print 'WeakValueDictionary error'
+... print('WeakValueDictionary error')
OK
"""
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 6df19c4..3e214f8 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -184,9 +184,9 @@ def parseliteral():
>>> element = ET.fromstring("<html><body>text</body></html>")
>>> ET.ElementTree(element).write(sys.stdout)
<html><body>text</body></html>
- >>> print ET.tostring(element)
+ >>> print(ET.tostring(element))
<html><body>text</body></html>
- >>> print ET.tostring(element, "ascii")
+ >>> print(ET.tostring(element, "ascii"))
<?xml version='1.0' encoding='ascii'?>
<html><body>text</body></html>
>>> _, ids = ET.XMLID("<html><body>text</body></html>")
@@ -301,7 +301,7 @@ def xinclude():
>>> document = xinclude_loader("C1.xml")
>>> ElementInclude.include(document, xinclude_loader)
- >>> print serialize(ET, document) # C1
+ >>> print(serialize(ET, document)) # C1
<document>
<p>120 Mz is adequate for an average home user.</p>
<disclaimer>
@@ -315,7 +315,7 @@ def xinclude():
>>> document = xinclude_loader("C2.xml")
>>> ElementInclude.include(document, xinclude_loader)
- >>> print serialize(ET, document) # C2
+ >>> print(serialize(ET, document)) # C2
<document>
<p>This document has been accessed
324387 times.</p>
@@ -325,7 +325,7 @@ def xinclude():
>>> document = xinclude_loader("C3.xml")
>>> ElementInclude.include(document, xinclude_loader)
- >>> print serialize(ET, document) # C3
+ >>> print(serialize(ET, document)) # C3
<document>
<p>The following is the source of the "data.xml" resource:</p>
<example>&lt;?xml version='1.0'?&gt;
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index 75b5a82..d9760c6 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -176,9 +176,9 @@ def parseliteral():
>>> element = ET.fromstring("<html><body>text</body></html>")
>>> ET.ElementTree(element).write(sys.stdout)
<html><body>text</body></html>
- >>> print ET.tostring(element)
+ >>> print(ET.tostring(element))
<html><body>text</body></html>
- >>> print ET.tostring(element, "ascii")
+ >>> print(ET.tostring(element, "ascii"))
<?xml version='1.0' encoding='ascii'?>
<html><body>text</body></html>
>>> _, ids = ET.XMLID("<html><body>text</body></html>")