summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-02-09 05:37:30 (GMT)
committerGuido van Rossum <guido@python.org>2007-02-09 05:37:30 (GMT)
commitbe19ed77ddb047e02fe94d142181062af6d99dcc (patch)
tree70f214e06554046fcccbadeb78665f25e07ce965 /Lib/test/test_descr.py
parent452bf519a70c3db0e7f0d2540b1bfb07d9085583 (diff)
downloadcpython-be19ed77ddb047e02fe94d142181062af6d99dcc.zip
cpython-be19ed77ddb047e02fe94d142181062af6d99dcc.tar.gz
cpython-be19ed77ddb047e02fe94d142181062af6d99dcc.tar.bz2
Fix most trivially-findable print statements.
There's one major and one minor category still unfixed: doctests are the major category (and I hope to be able to augment the refactoring tool to refactor bona fide doctests soon); other code generating print statements in strings is the minor category. (Oh, and I don't know if the compiler package works.)
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py222
1 files changed, 111 insertions, 111 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index bcfadf7..aab3331 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -13,7 +13,7 @@ def veris(a, b):
raise TestFailed, "%r is %r" % (a, b)
def testunop(a, res, expr="len(a)", meth="__len__"):
- if verbose: print "checking", expr
+ if verbose: print("checking", expr)
dict = {'a': a}
vereq(eval(expr, dict), res)
t = type(a)
@@ -26,7 +26,7 @@ def testunop(a, res, expr="len(a)", meth="__len__"):
vereq(bm(), res)
def testbinop(a, b, res, expr="a+b", meth="__add__"):
- if verbose: print "checking", expr
+ if verbose: print("checking", expr)
dict = {'a': a, 'b': b}
vereq(eval(expr, dict), res)
@@ -40,7 +40,7 @@ def testbinop(a, b, res, expr="a+b", meth="__add__"):
vereq(bm(b), res)
def testternop(a, b, c, res, expr="a[b:c]", meth="__getslice__"):
- if verbose: print "checking", expr
+ if verbose: print("checking", expr)
dict = {'a': a, 'b': b, 'c': c}
vereq(eval(expr, dict), res)
t = type(a)
@@ -53,7 +53,7 @@ def testternop(a, b, c, res, expr="a[b:c]", meth="__getslice__"):
vereq(bm(b, c), res)
def testsetop(a, b, res, stmt="a+=b", meth="__iadd__"):
- if verbose: print "checking", stmt
+ if verbose: print("checking", stmt)
dict = {'a': deepcopy(a), 'b': b}
exec(stmt, dict)
vereq(dict['a'], res)
@@ -71,7 +71,7 @@ def testsetop(a, b, res, stmt="a+=b", meth="__iadd__"):
vereq(dict['a'], res)
def testset2op(a, b, c, res, stmt="a[b]=c", meth="__setitem__"):
- if verbose: print "checking", stmt
+ if verbose: print("checking", stmt)
dict = {'a': deepcopy(a), 'b': b, 'c': c}
exec(stmt, dict)
vereq(dict['a'], res)
@@ -89,7 +89,7 @@ def testset2op(a, b, c, res, stmt="a[b]=c", meth="__setitem__"):
vereq(dict['a'], res)
def testset3op(a, b, c, d, res, stmt="a[b:c]=d", meth="__setslice__"):
- if verbose: print "checking", stmt
+ if verbose: print("checking", stmt)
dict = {'a': deepcopy(a), 'b': b, 'c': c, 'd': d}
exec(stmt, dict)
vereq(dict['a'], res)
@@ -135,7 +135,7 @@ def class_docstrings():
verify(NewDynamic2.__doc__ is None)
def lists():
- if verbose: print "Testing list operations..."
+ if verbose: print("Testing list operations...")
testbinop([1], [2], [1,2], "a+b", "__add__")
testbinop([1,2,3], 2, 1, "b in a", "__contains__")
testbinop([1,2,3], 4, 0, "b in a", "__contains__")
@@ -150,7 +150,7 @@ def lists():
testset3op([1,2,3,4], 1, 3, [5,6], [1,5,6,4], "a[b:c]=d", "__setslice__")
def dicts():
- if verbose: print "Testing dict operations..."
+ if verbose: print("Testing dict operations...")
##testbinop({1:2}, {2:1}, -1, "cmp(a,b)", "__cmp__")
testbinop({1:2,3:4}, 1, 1, "b in a", "__contains__")
testbinop({1:2,3:4}, 2, 0, "b in a", "__contains__")
@@ -175,7 +175,7 @@ def dicts():
def dict_constructor():
if verbose:
- print "Testing dict constructor ..."
+ print("Testing dict constructor ...")
d = dict()
vereq(d, {})
d = dict({})
@@ -258,7 +258,7 @@ def dict_constructor():
def test_dir():
if verbose:
- print "Testing dir() ..."
+ print("Testing dir() ...")
junk = 12
vereq(dir(), ['junk'])
del junk
@@ -413,7 +413,7 @@ def numops(a, b, skip=[]):
testunop(a, res, expr, name)
def ints():
- if verbose: print "Testing int operations..."
+ if verbose: print("Testing int operations...")
numops(100, 3)
# The following crashes in Python 2.2
vereq((1).__bool__(), True)
@@ -431,15 +431,15 @@ def ints():
raise TestFailed, "NotImplemented should have caused TypeError"
def longs():
- if verbose: print "Testing long operations..."
+ if verbose: print("Testing long operations...")
numops(100, 3)
def floats():
- if verbose: print "Testing float operations..."
+ if verbose: print("Testing float operations...")
numops(100.0, 3.0)
def complexes():
- if verbose: print "Testing complex operations..."
+ if verbose: print("Testing complex operations...")
numops(100.0j, 3.0j, skip=['lt', 'le', 'gt', 'ge', 'int', 'long', 'float'])
class Number(complex):
__slots__ = ['prec']
@@ -469,7 +469,7 @@ def complexes():
vereq(a.prec, 12)
def spamlists():
- if verbose: print "Testing spamlist operations..."
+ if verbose: print("Testing spamlist operations...")
import copy, xxsubtype as spam
def spamlist(l, memo=None):
import xxsubtype as spam
@@ -505,7 +505,7 @@ def spamlists():
vereq(a.getstate(), 42)
def spamdicts():
- if verbose: print "Testing spamdict operations..."
+ if verbose: print("Testing spamdict operations...")
import copy, xxsubtype as spam
def spamdict(d, memo=None):
import xxsubtype as spam
@@ -550,7 +550,7 @@ def spamdicts():
vereq(a.getstate(), 100)
def pydicts():
- if verbose: print "Testing Python subclass of dict..."
+ if verbose: print("Testing Python subclass of dict...")
verify(issubclass(dict, dict))
verify(isinstance({}, dict))
d = dict()
@@ -591,7 +591,7 @@ def pydicts():
vereq(a[42], 0)
a[42] = 24
vereq(a[42], 24)
- if verbose: print "pydict stress test ..."
+ if verbose: print("pydict stress test ...")
N = 50
for i in range(N):
a[i] = C()
@@ -602,7 +602,7 @@ def pydicts():
vereq(a[i][j], i*j)
def pylists():
- if verbose: print "Testing Python subclass of list..."
+ if verbose: print("Testing Python subclass of list...")
class C(list):
def __getitem__(self, i):
return list.__getitem__(self, i) + 100
@@ -616,7 +616,7 @@ def pylists():
vereq(a[100:200], (100,200))
def metaclass():
- if verbose: print "Testing __metaclass__..."
+ if verbose: print("Testing __metaclass__...")
class C:
__metaclass__ = type
def __init__(self):
@@ -778,7 +778,7 @@ def metaclass():
else: raise TestFailed, "calling object w/o call method should raise TypeError"
def pymods():
- if verbose: print "Testing Python subclass of module..."
+ if verbose: print("Testing Python subclass of module...")
log = []
import sys
MT = type(sys)
@@ -803,7 +803,7 @@ def pymods():
("delattr", "foo")])
def multi():
- if verbose: print "Testing multiple inheritance..."
+ if verbose: print("Testing multiple inheritance...")
class C(object):
def __init__(self):
self.__state = 0
@@ -844,7 +844,7 @@ def multi():
vereq(int(Frag()), 42)
def diamond():
- if verbose: print "Testing multiple inheritance special cases..."
+ if verbose: print("Testing multiple inheritance special cases...")
class A(object):
def spam(self): return "A"
vereq(A().spam(), "A")
@@ -882,7 +882,7 @@ def diamond():
# see thread python-dev/2002-October/029035.html
def ex5():
- if verbose: print "Testing ex5 from C3 switch discussion..."
+ if verbose: print("Testing ex5 from C3 switch discussion...")
class A(object): pass
class B(object): pass
class C(object): pass
@@ -894,7 +894,7 @@ def ex5():
# see "A Monotonic Superclass Linearization for Dylan",
# by Kim Barrett et al. (OOPSLA 1996)
def monotonicity():
- if verbose: print "Testing MRO monotonicity..."
+ if verbose: print("Testing MRO monotonicity...")
class Boat(object): pass
class DayBoat(Boat): pass
class WheelBoat(Boat): pass
@@ -917,7 +917,7 @@ def monotonicity():
# see "A Monotonic Superclass Linearization for Dylan",
# by Kim Barrett et al. (OOPSLA 1996)
def consistency_with_epg():
- if verbose: print "Testing consistentcy with EPG..."
+ if verbose: print("Testing consistentcy with EPG...")
class Pane(object): pass
class ScrollingMixin(object): pass
class EditingMixin(object): pass
@@ -933,7 +933,7 @@ mro_err_msg = """Cannot create a consistent method resolution
order (MRO) for bases """
def mro_disagreement():
- if verbose: print "Testing error messages for MRO disagreement..."
+ if verbose: print("Testing error messages for MRO disagreement...")
def raises(exc, expected, callable, *args):
try:
callable(*args)
@@ -963,7 +963,7 @@ def mro_disagreement():
type, "ConfusedGrid", (HVGrid, VHGrid), {})
def objects():
- if verbose: print "Testing object class..."
+ if verbose: print("Testing object class...")
a = object()
vereq(a.__class__, object)
vereq(type(a), object)
@@ -987,7 +987,7 @@ def objects():
vereq(x.__dict__, {'foo': 1})
def slots():
- if verbose: print "Testing __slots__..."
+ if verbose: print("Testing __slots__...")
class C0(object):
__slots__ = []
x = C0()
@@ -1152,7 +1152,7 @@ def slots():
sys.stderr = save_stderr
def slotspecials():
- if verbose: print "Testing __dict__ and __weakref__ in __slots__..."
+ if verbose: print("Testing __dict__ and __weakref__ in __slots__...")
class D(object):
__slots__ = ["__dict__"]
@@ -1199,7 +1199,7 @@ def slotspecials():
# __slots__ = []
def dynamics():
- if verbose: print "Testing class attribute propagation..."
+ if verbose: print("Testing class attribute propagation...")
class D(object):
pass
class E(D):
@@ -1278,7 +1278,7 @@ def dynamics():
verify(someclass != object)
def errors():
- if verbose: print "Testing errors..."
+ if verbose: print("Testing errors...")
try:
class C(list, dict):
@@ -1323,7 +1323,7 @@ def errors():
verify(0, "__slots__ = [1] should be illegal")
def classmethods():
- if verbose: print "Testing class methods..."
+ if verbose: print("Testing class methods...")
class C(object):
def foo(*a): return a
goo = classmethod(foo)
@@ -1369,7 +1369,7 @@ def classmethods():
raise TestFailed, "classmethod shouldn't accept keyword args"
def classmethods_in_c():
- if verbose: print "Testing C-based class methods..."
+ if verbose: print("Testing C-based class methods...")
import xxsubtype as spam
a = (1, 2, 3)
d = {'abc': 123}
@@ -1383,7 +1383,7 @@ def classmethods_in_c():
vereq(d, d1)
def staticmethods():
- if verbose: print "Testing static methods..."
+ if verbose: print("Testing static methods...")
class C(object):
def foo(*a): return a
goo = staticmethod(foo)
@@ -1400,7 +1400,7 @@ def staticmethods():
vereq(D.foo(d, 1), (d, 1))
def staticmethods_in_c():
- if verbose: print "Testing C-based static methods..."
+ if verbose: print("Testing C-based static methods...")
import xxsubtype as spam
a = (1, 2, 3)
d = {"abc": 123}
@@ -1414,7 +1414,7 @@ def staticmethods_in_c():
vereq(d, d1)
def classic():
- if verbose: print "Testing classic classes..."
+ if verbose: print("Testing classic classes...")
class C:
def foo(*a): return a
goo = classmethod(foo)
@@ -1435,7 +1435,7 @@ def classic():
verify(repr(C.foo.__get__(C())).startswith("<bound method "))
def compattr():
- if verbose: print "Testing computed attributes..."
+ if verbose: print("Testing computed attributes...")
class C(object):
class computed_attribute(object):
def __init__(self, get, set=None, delete=None):
@@ -1469,7 +1469,7 @@ def compattr():
vereq(hasattr(a, 'x'), 0)
def newslot():
- if verbose: print "Testing __new__ slot override..."
+ if verbose: print("Testing __new__ slot override...")
class C(list):
def __new__(cls):
self = list.__new__(cls)
@@ -1487,7 +1487,7 @@ def newslot():
verify(b.__class__ is D)
def altmro():
- if verbose: print "Testing mro() and overriding it..."
+ if verbose: print("Testing mro() and overriding it...")
class A(object):
def f(self): return "A"
class B(A):
@@ -1542,7 +1542,7 @@ def altmro():
def overloading():
- if verbose: print "Testing operator overloading..."
+ if verbose: print("Testing operator overloading...")
class B(object):
"Intermediate class because object doesn't have a __setattr__"
@@ -1599,7 +1599,7 @@ def overloading():
vereq(a.delslice, (0, 10))
def methods():
- if verbose: print "Testing methods..."
+ if verbose: print("Testing methods...")
class C(object):
def __init__(self, x):
self.x = x
@@ -1621,7 +1621,7 @@ def methods():
def specials():
# Test operators like __hash__ for which a built-in default exists
- if verbose: print "Testing special operators..."
+ if verbose: print("Testing special operators...")
# Test the default behavior for static classes
class C(object):
def __getitem__(self, i):
@@ -1782,7 +1782,7 @@ def specials():
sys.stdout = get_original_stdout()
try:
# nothing should actually be printed, this should raise an exception
- print Letter('w')
+ print(Letter('w'))
except RuntimeError:
pass
else:
@@ -1790,7 +1790,7 @@ def specials():
sys.stdout = test_stdout
def weakrefs():
- if verbose: print "Testing weak references..."
+ if verbose: print("Testing weak references...")
import weakref
class C(object):
pass
@@ -1819,7 +1819,7 @@ def weakrefs():
del r
def properties():
- if verbose: print "Testing property..."
+ if verbose: print("Testing property...")
class C(object):
def getx(self):
return self.__x
@@ -1902,7 +1902,7 @@ def properties():
def supers():
- if verbose: print "Testing super..."
+ if verbose: print("Testing super...")
class A(object):
def meth(self, a):
@@ -2018,7 +2018,7 @@ def supers():
raise TestFailed, "super shouldn't accept keyword args"
def inherits():
- if verbose: print "Testing inheritance from basic types..."
+ if verbose: print("Testing inheritance from basic types...")
class hexint(int):
def __repr__(self):
@@ -2362,7 +2362,7 @@ def inherits():
def keywords():
if verbose:
- print "Testing keyword args to basic type constructors ..."
+ print("Testing keyword args to basic type constructors ...")
vereq(int(x=1), 1)
vereq(float(x=2), 2.0)
vereq(int(x=3), 3)
@@ -2388,7 +2388,7 @@ def restricted():
return
import rexec
if verbose:
- print "Testing interaction with restricted execution ..."
+ print("Testing interaction with restricted execution ...")
sandbox = rexec.RExec()
@@ -2428,7 +2428,7 @@ f = t(%r, 'w') # rexec can't catch this by itself
def str_subclass_as_dict_key():
if verbose:
- print "Testing a str subclass used as dict key .."
+ print("Testing a str subclass used as dict key ..")
class cistr(str):
"""Sublcass of str that computes __eq__ case-insensitively.
@@ -2460,11 +2460,11 @@ def str_subclass_as_dict_key():
vereq(d.get(cistr('thrEE')), 3)
def classic_comparisons():
- if verbose: print "Testing classic comparisons..."
+ if verbose: print("Testing classic comparisons...")
class classic:
pass
for base in (classic, int, object):
- if verbose: print " (base = %s)" % base
+ if verbose: print(" (base = %s)" % base)
class C(base):
def __init__(self, value):
self.value = int(value)
@@ -2521,7 +2521,7 @@ def classic_comparisons():
def rich_comparisons():
if verbose:
- print "Testing rich comparisons..."
+ print("Testing rich comparisons...")
class Z(complex):
pass
z = Z(1)
@@ -2540,7 +2540,7 @@ def rich_comparisons():
class classic:
pass
for base in (classic, int, object, list):
- if verbose: print " (base = %s)" % base
+ if verbose: print(" (base = %s)" % base)
class C(base):
def __init__(self, value):
self.value = int(value)
@@ -2598,14 +2598,14 @@ def rich_comparisons():
"x=%d, y=%d" % (x, y))
def descrdoc():
- if verbose: print "Testing descriptor doc strings..."
+ if verbose: print("Testing descriptor doc strings...")
def check(descr, what):
vereq(descr.__doc__, what)
check(file.closed, "True if the file is closed") # getset descriptor
check(file.name, "file name") # member descriptor
def setclass():
- if verbose: print "Testing __class__ assignment..."
+ if verbose: print("Testing __class__ assignment...")
class C(object): pass
class D(object): pass
class E(object): pass
@@ -2647,7 +2647,7 @@ def setclass():
del o
def setdict():
- if verbose: print "Testing __dict__ assignment..."
+ if verbose: print("Testing __dict__ assignment...")
class C(object): pass
a = C()
a.__dict__ = {'b': 1}
@@ -2668,7 +2668,7 @@ def setdict():
def pickles():
if verbose:
- print "Testing pickling and copying new-style classes and objects..."
+ print("Testing pickling and copying new-style classes and objects...")
import pickle
try:
import cPickle
@@ -2733,7 +2733,7 @@ def pickles():
continue # cPickle not found -- skip it
for bin in 0, 1:
if verbose:
- print p.__name__, ["text", "binary"][bin]
+ print(p.__name__, ["text", "binary"][bin])
for cls in C, C1, C2:
s = p.dumps(cls, bin)
@@ -2751,8 +2751,8 @@ def pickles():
vereq(repr(x), repr(a))
vereq(repr(y), repr(b))
if verbose:
- print "a = x =", a
- print "b = y =", b
+ print("a = x =", a)
+ print("b = y =", b)
# Test for __getstate__ and __setstate__ on new style class
u = C3(42)
s = p.dumps(u, bin)
@@ -2769,7 +2769,7 @@ def pickles():
# Testing copy.deepcopy()
if verbose:
- print "deepcopy"
+ print("deepcopy")
import copy
for cls in C, C1, C2:
cls2 = copy.deepcopy(cls)
@@ -2785,11 +2785,11 @@ def pickles():
vereq(repr(x), repr(a))
vereq(repr(y), repr(b))
if verbose:
- print "a = x =", a
- print "b = y =", b
+ print("a = x =", a)
+ print("b = y =", b)
def pickleslots():
- if verbose: print "Testing pickling of classes with __slots__ ..."
+ if verbose: print("Testing pickling of classes with __slots__ ...")
import pickle, pickle as cPickle
# Pickling of classes with __slots__ but without __getstate__ should fail
global B, C, D, E
@@ -2876,7 +2876,7 @@ def pickleslots():
vereq(y.b, x.b)
def copies():
- if verbose: print "Testing copy.copy() and copy.deepcopy()..."
+ if verbose: print("Testing copy.copy() and copy.deepcopy()...")
import copy
class C(object):
pass
@@ -2897,7 +2897,7 @@ def copies():
vereq(d.bar, [1,2,3])
def binopoverride():
- if verbose: print "Testing overrides of binary operations..."
+ if verbose: print("Testing overrides of binary operations...")
class I(int):
def __repr__(self):
return "I(%r)" % int(self)
@@ -2927,7 +2927,7 @@ def binopoverride():
return self.lower() == other.lower()
def subclasspropagation():
- if verbose: print "Testing propagation of slot functions to subclasses..."
+ if verbose: print("Testing propagation of slot functions to subclasses...")
class A(object):
pass
class B(A):
@@ -3000,7 +3000,7 @@ def buffer_inherit():
import binascii
# SF bug [#470040] ParseTuple t# vs subclasses.
if verbose:
- print "Testing that buffer interface is inherited ..."
+ print("Testing that buffer interface is inherited ...")
class MyStr(str):
pass
@@ -3032,7 +3032,7 @@ def str_of_str_subclass():
import cStringIO
if verbose:
- print "Testing __str__ defined in subclass of str ..."
+ print("Testing __str__ defined in subclass of str ...")
class octetstring(str):
def __str__(self):
@@ -3052,13 +3052,13 @@ def str_of_str_subclass():
capture = cStringIO.StringIO()
# Calling str() or not exercises different internal paths.
- print >> capture, o
- print >> capture, str(o)
+ print(o, file=capture)
+ print(str(o), file=capture)
vereq(capture.getvalue(), '41\n41\n')
capture.close()
def kwdargs():
- if verbose: print "Testing keyword arguments to __init__, __call__..."
+ if verbose: print("Testing keyword arguments to __init__, __call__...")
def f(a): return a
vereq(f.__call__(a=42), 42)
a = []
@@ -3066,8 +3066,8 @@ def kwdargs():
vereq(a, [0, 1, 2])
def recursive__call__():
- if verbose: print ("Testing recursive __call__() by setting to instance of "
- "class ...")
+ if verbose: print(("Testing recursive __call__() by setting to instance of "
+ "class ..."))
class A(object):
pass
@@ -3081,7 +3081,7 @@ def recursive__call__():
"__call__()")
def delhook():
- if verbose: print "Testing __del__ hook..."
+ if verbose: print("Testing __del__ hook...")
log = []
class C(object):
def __del__(self):
@@ -3098,7 +3098,7 @@ def delhook():
else: raise TestFailed, "invalid del() didn't raise TypeError"
def hashinherit():
- if verbose: print "Testing hash of mutable subclasses..."
+ if verbose: print("Testing hash of mutable subclasses...")
class mydict(dict):
pass
@@ -3167,7 +3167,7 @@ def strops():
vereq('%c' % '5', '5')
def deepcopyrecursive():
- if verbose: print "Testing deepcopy of recursive objects..."
+ if verbose: print("Testing deepcopy of recursive objects...")
class Node:
pass
a = Node()
@@ -3177,7 +3177,7 @@ def deepcopyrecursive():
z = deepcopy(a) # This blew up before
def modules():
- if verbose: print "Testing uninitialized module objects..."
+ if verbose: print("Testing uninitialized module objects...")
from types import ModuleType as M
m = M.__new__(M)
str(m)
@@ -3192,7 +3192,7 @@ def dictproxyiterkeys():
class C(object):
def meth(self):
pass
- if verbose: print "Testing dict-proxy iterkeys..."
+ if verbose: print("Testing dict-proxy iterkeys...")
keys = [ key for key in C.__dict__.iterkeys() ]
keys.sort()
vereq(keys, ['__dict__', '__doc__', '__module__', '__weakref__', 'meth'])
@@ -3201,7 +3201,7 @@ def dictproxyitervalues():
class C(object):
def meth(self):
pass
- if verbose: print "Testing dict-proxy itervalues..."
+ if verbose: print("Testing dict-proxy itervalues...")
values = [ values for values in C.__dict__.itervalues() ]
vereq(len(values), 5)
@@ -3209,13 +3209,13 @@ def dictproxyiteritems():
class C(object):
def meth(self):
pass
- if verbose: print "Testing dict-proxy iteritems..."
+ if verbose: print("Testing dict-proxy iteritems...")
keys = [ key for (key, value) in C.__dict__.iteritems() ]
keys.sort()
vereq(keys, ['__dict__', '__doc__', '__module__', '__weakref__', 'meth'])
def funnynew():
- if verbose: print "Testing __new__ returning something unexpected..."
+ if verbose: print("Testing __new__ returning something unexpected...")
class C(object):
def __new__(cls, arg):
if isinstance(arg, str): return [1, 2, 3]
@@ -3237,7 +3237,7 @@ def funnynew():
def imulbug():
# SF bug 544647
- if verbose: print "Testing for __imul__ problems..."
+ if verbose: print("Testing for __imul__ problems...")
class C(object):
def __imul__(self, other):
return (self, other)
@@ -3263,7 +3263,7 @@ def imulbug():
def docdescriptor():
# SF bug 542984
- if verbose: print "Testing __doc__ descriptor..."
+ if verbose: print("Testing __doc__ descriptor...")
class DocDescr(object):
def __get__(self, object, otype):
if object:
@@ -3282,7 +3282,7 @@ def docdescriptor():
def copy_setstate():
if verbose:
- print "Testing that copy.*copy() correctly uses __setstate__..."
+ print("Testing that copy.*copy() correctly uses __setstate__...")
import copy
class C(object):
def __init__(self, foo=None):
@@ -3310,7 +3310,7 @@ def copy_setstate():
def slices():
if verbose:
- print "Testing cases with slices and overridden __getitem__ ..."
+ print("Testing cases with slices and overridden __getitem__ ...")
# Strings
vereq("hello"[:4], "hell")
vereq("hello"[slice(4)], "hell")
@@ -3354,7 +3354,7 @@ def slices():
def subtype_resurrection():
if verbose:
- print "Testing resurrection of new-style instance..."
+ print("Testing resurrection of new-style instance...")
class C(object):
container = []
@@ -3384,7 +3384,7 @@ def subtype_resurrection():
def slottrash():
# Deallocating deeply nested slotted trash caused stack overflows
if verbose:
- print "Testing slot trash..."
+ print("Testing slot trash...")
class trash(object):
__slots__ = ['x']
def __init__(self, x):
@@ -3410,7 +3410,7 @@ def slotmultipleinheritance():
def testrmul():
# SF patch 592646
if verbose:
- print "Testing correct invocation of __rmul__..."
+ print("Testing correct invocation of __rmul__...")
class C(object):
def __mul__(self, other):
return "mul"
@@ -3425,7 +3425,7 @@ def testrmul():
def testipow():
# [SF bug 620179]
if verbose:
- print "Testing correct invocation of __ipow__..."
+ print("Testing correct invocation of __ipow__...")
class C(object):
def __ipow__(self, other):
pass
@@ -3434,7 +3434,7 @@ def testipow():
def do_this_first():
if verbose:
- print "Testing SF bug 551412 ..."
+ print("Testing SF bug 551412 ...")
# This dumps core when SF bug 551412 isn't fixed --
# but only when test_descr.py is run separately.
# (That can't be helped -- as soon as PyType_Ready()
@@ -3448,14 +3448,14 @@ def do_this_first():
pass
if verbose:
- print "Testing SF bug 570483..."
+ print("Testing SF bug 570483...")
# Another segfault only when run early
# (before PyType_Ready(tuple) is called)
type.mro(tuple)
def test_mutable_bases():
if verbose:
- print "Testing mutable bases..."
+ print("Testing mutable bases...")
# stuff that should work:
class C(object):
pass
@@ -3545,7 +3545,7 @@ def test_mutable_bases():
def test_mutable_bases_with_failing_mro():
if verbose:
- print "Testing mutable bases with failing mro..."
+ print("Testing mutable bases with failing mro...")
class WorkOnce(type):
def __new__(self, name, bases, ns):
self.flag = 0
@@ -3600,7 +3600,7 @@ def test_mutable_bases_with_failing_mro():
def test_mutable_bases_catch_mro_conflict():
if verbose:
- print "Testing mutable bases catch mro conflict..."
+ print("Testing mutable bases catch mro conflict...")
class A(object):
pass
@@ -3625,7 +3625,7 @@ def test_mutable_bases_catch_mro_conflict():
def mutable_names():
if verbose:
- print "Testing mutable names..."
+ print("Testing mutable names...")
class C(object):
pass
@@ -3640,7 +3640,7 @@ def mutable_names():
def subclass_right_op():
if verbose:
- print "Testing correct dispatch of subclass overloading __r<op>__..."
+ print("Testing correct dispatch of subclass overloading __r<op>__...")
# This code tests various cases where right-dispatch of a subclass
# should be preferred over left-dispatch of a base class.
@@ -3692,7 +3692,7 @@ def subclass_right_op():
def dict_type_with_metaclass():
if verbose:
- print "Testing type of __dict__ when __metaclass__ set..."
+ print("Testing type of __dict__ when __metaclass__ set...")
class B(object):
pass
@@ -3706,7 +3706,7 @@ def dict_type_with_metaclass():
def meth_class_get():
# Full coverage of descrobject.c::classmethod_get()
if verbose:
- print "Testing __get__ method of METH_CLASS C methods..."
+ print("Testing __get__ method of METH_CLASS C methods...")
# Baseline
arg = [1, 2, 3]
res = {1: None, 2: None, 3: None}
@@ -3745,7 +3745,7 @@ def meth_class_get():
def isinst_isclass():
if verbose:
- print "Testing proxy isinstance() and isclass()..."
+ print("Testing proxy isinstance() and isclass()...")
class Proxy(object):
def __init__(self, obj):
self.__obj = obj
@@ -3785,7 +3785,7 @@ def isinst_isclass():
def proxysuper():
if verbose:
- print "Testing super() for a proxy object..."
+ print("Testing super() for a proxy object...")
class Proxy(object):
def __init__(self, obj):
self.__obj = obj
@@ -3809,7 +3809,7 @@ def proxysuper():
def carloverre():
if verbose:
- print "Testing prohibition of Carlo Verre's hack..."
+ print("Testing prohibition of Carlo Verre's hack...")
try:
object.__setattr__(str, "foo", 42)
except TypeError:
@@ -3826,7 +3826,7 @@ def carloverre():
def weakref_segfault():
# SF 742911
if verbose:
- print "Testing weakref segfault..."
+ print("Testing weakref segfault...")
import weakref
@@ -3854,7 +3854,7 @@ def wrapper_segfault():
# Fix SF #762455, segfault when sys.stdout is changed in getattr
def filefault():
if verbose:
- print "Testing sys.stdout is changed in getattr..."
+ print("Testing sys.stdout is changed in getattr...")
import sys
class StdoutGuard:
def __getattr__(self, attr):
@@ -3862,7 +3862,7 @@ def filefault():
raise RuntimeError("Premature access to sys.stdout.%s" % attr)
sys.stdout = StdoutGuard()
try:
- print "Oops!"
+ print("Oops!")
except RuntimeError:
pass
@@ -3871,7 +3871,7 @@ def vicious_descriptor_nonsense():
# python-dev 2003-04-17, turned into an example & fixed by Michael
# Hudson just less than four months later...
if verbose:
- print "Testing vicious_descriptor_nonsense..."
+ print("Testing vicious_descriptor_nonsense...")
class Evil(object):
def __hash__(self):
@@ -3910,7 +3910,7 @@ def test_init():
def methodwrapper():
# <type 'method-wrapper'> did not support any reflection before 2.5
if verbose:
- print "Testing method-wrapper objects..."
+ print("Testing method-wrapper objects...")
return # XXX should methods really support __eq__?
@@ -3938,7 +3938,7 @@ def methodwrapper():
def notimplemented():
# all binary methods should be able to return a NotImplemented
if verbose:
- print "Testing NotImplemented..."
+ print("Testing NotImplemented...")
import sys
import types
@@ -4098,7 +4098,7 @@ def test_main():
methodwrapper()
notimplemented()
- if verbose: print "All OK"
+ if verbose: print("All OK")
if __name__ == "__main__":
test_main()