summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2004-02-12 17:35:32 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2004-02-12 17:35:32 (GMT)
commit70a6b49821a3226f55e9716f32d802d06640cb89 (patch)
tree3c8ca10c1fa09e025bd266cf855a00d7d96c55aa /Lib/test
parentecfeb7f095dfd9c1c8929bf3df858ee35e0d9e9e (diff)
downloadcpython-70a6b49821a3226f55e9716f32d802d06640cb89.zip
cpython-70a6b49821a3226f55e9716f32d802d06640cb89.tar.gz
cpython-70a6b49821a3226f55e9716f32d802d06640cb89.tar.bz2
Replace backticks with repr() or "%r"
From SF patch #852334.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asynchat.py2
-rw-r--r--Lib/test/test_builtin.py4
-rw-r--r--Lib/test/test_contains.py12
-rw-r--r--Lib/test/test_copy.py4
-rw-r--r--Lib/test/test_descr.py28
-rwxr-xr-xLib/test/test_fcntl.py4
-rw-r--r--Lib/test/test_generators.py2
-rw-r--r--Lib/test/test_grammar.py4
-rw-r--r--Lib/test/test_hash.py2
-rw-r--r--Lib/test/test_math.py8
-rw-r--r--Lib/test/test_minidom.py2
-rw-r--r--Lib/test/test_mpz.py2
-rw-r--r--Lib/test/test_poll.py2
-rw-r--r--Lib/test/test_popen2.py6
-rw-r--r--Lib/test/test_pprint.py26
-rw-r--r--Lib/test/test_pty.py2
-rw-r--r--Lib/test/test_pyexpat.py6
-rw-r--r--Lib/test/test_repr.py8
-rw-r--r--Lib/test/test_rotor.py4
-rw-r--r--Lib/test/test_select.py2
-rw-r--r--Lib/test/test_set.py4
-rw-r--r--Lib/test/test_sets.py4
-rw-r--r--Lib/test/test_socketserver.py2
-rw-r--r--Lib/test/test_struct.py18
-rw-r--r--Lib/test/test_syntax.py2
-rw-r--r--Lib/test/test_types.py4
-rw-r--r--Lib/test/test_univnewlines.py6
-rw-r--r--Lib/test/test_weakref.py2
28 files changed, 86 insertions, 86 deletions
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py
index 60017e0..e91c572 100644
--- a/Lib/test/test_asynchat.py
+++ b/Lib/test/test_asynchat.py
@@ -42,7 +42,7 @@ class echo_client(asynchat.async_chat):
self.buffer = self.buffer + data
def found_terminator(self):
- print "Received:", `self.buffer`
+ print "Received:", repr(self.buffer)
self.buffer = ""
self.close()
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 46f3d68..9aa24c2 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -58,7 +58,7 @@ L = [
(' 314', 314),
('314 ', 314),
(' \t\t 314 \t\t ', 314),
- (`sys.maxint`, sys.maxint),
+ (repr(sys.maxint), sys.maxint),
(' 1x', ValueError),
(' 1 ', 1),
(' 1\02 ', ValueError),
@@ -480,7 +480,7 @@ class BuiltinTest(unittest.TestCase):
except v:
pass
- s = `-1-sys.maxint`
+ s = repr(-1-sys.maxint)
self.assertEqual(int(s)+1, -sys.maxint)
# should return long
int(s[1:])
diff --git a/Lib/test/test_contains.py b/Lib/test/test_contains.py
index 04eedf1..e6f5cf7 100644
--- a/Lib/test/test_contains.py
+++ b/Lib/test/test_contains.py
@@ -88,15 +88,15 @@ if have_unicode:
# A collection of tests on builtin sequence types
a = range(10)
for i in a:
- check(i in a, "%s not in %s" % (`i`, `a`))
-check(16 not in a, "16 not in %s" % `a`)
-check(a not in a, "%s not in %s" % (`a`, `a`))
+ check(i in a, "%r not in %r" % (i, a))
+check(16 not in a, "16 not in %r" % (a,))
+check(a not in a, "%s not in %r" % (a, a))
a = tuple(a)
for i in a:
- check(i in a, "%s not in %s" % (`i`, `a`))
-check(16 not in a, "16 not in %s" % `a`)
-check(a not in a, "%s not in %s" % (`a`, `a`))
+ check(i in a, "%r not in %r" % (i, a))
+check(16 not in a, "16 not in %r" % (a,))
+check(a not in a, "%r not in %r" % (a, a))
class Deviant1:
"""Behaves strangely when compared
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index 6e32ddd..bd5a3e1 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -86,7 +86,7 @@ class TestCopy(unittest.TestCase):
"hello", u"hello\u1234", f.func_code,
NewStyle, xrange(10), Classic, max]
for x in tests:
- self.assert_(copy.copy(x) is x, `x`)
+ self.assert_(copy.copy(x) is x, repr(x))
def test_copy_list(self):
x = [1, 2, 3]
@@ -259,7 +259,7 @@ class TestCopy(unittest.TestCase):
"hello", u"hello\u1234", f.func_code,
NewStyle, xrange(10), Classic, max]
for x in tests:
- self.assert_(copy.deepcopy(x) is x, `x`)
+ self.assert_(copy.deepcopy(x) is x, repr(x))
def test_deepcopy_list(self):
x = [[1, 2], 3]
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index d0500e6..ccb9fe6 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -500,15 +500,15 @@ def complexes():
__str__ = __repr__
a = Number(3.14, prec=6)
- vereq(`a`, "3.14")
+ vereq(repr(a), "3.14")
vereq(a.prec, 6)
a = Number(a, prec=2)
- vereq(`a`, "3.1")
+ vereq(repr(a), "3.1")
vereq(a.prec, 2)
a = Number(234.5)
- vereq(`a`, "234.5")
+ vereq(repr(a), "234.5")
vereq(a.prec, 12)
def spamlists():
@@ -2801,8 +2801,8 @@ def pickles():
vereq(sorteditems(x.__dict__), sorteditems(a.__dict__))
vereq(y.__class__, b.__class__)
vereq(sorteditems(y.__dict__), sorteditems(b.__dict__))
- vereq(`x`, `a`)
- vereq(`y`, `b`)
+ vereq(repr(x), repr(a))
+ vereq(repr(y), repr(b))
if verbose:
print "a = x =", a
print "b = y =", b
@@ -2835,8 +2835,8 @@ def pickles():
vereq(sorteditems(x.__dict__), sorteditems(a.__dict__))
vereq(y.__class__, b.__class__)
vereq(sorteditems(y.__dict__), sorteditems(b.__dict__))
- vereq(`x`, `a`)
- vereq(`y`, `b`)
+ vereq(repr(x), repr(a))
+ vereq(repr(y), repr(b))
if verbose:
print "a = x =", a
print "b = y =", b
@@ -2968,13 +2968,13 @@ def binopoverride():
else:
return I(pow(int(other), int(self), int(mod)))
- vereq(`I(1) + I(2)`, "I(3)")
- vereq(`I(1) + 2`, "I(3)")
- vereq(`1 + I(2)`, "I(3)")
- vereq(`I(2) ** I(3)`, "I(8)")
- vereq(`2 ** I(3)`, "I(8)")
- vereq(`I(2) ** 3`, "I(8)")
- vereq(`pow(I(2), I(3), I(5))`, "I(3)")
+ vereq(repr(I(1) + I(2)), "I(3)")
+ vereq(repr(I(1) + 2), "I(3)")
+ vereq(repr(1 + I(2)), "I(3)")
+ vereq(repr(I(2) ** I(3)), "I(8)")
+ vereq(repr(2 ** I(3)), "I(8)")
+ vereq(repr(I(2) ** 3), "I(8)")
+ vereq(repr(pow(I(2), I(3), I(5))), "I(3)")
class S(str):
def __eq__(self, other):
return self.lower() == other.lower()
diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py
index 530ca0c..1dabfa4 100755
--- a/Lib/test/test_fcntl.py
+++ b/Lib/test/test_fcntl.py
@@ -33,7 +33,7 @@ else:
lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
if lockdata:
if verbose:
- print 'struct.pack: ', `lockdata`
+ print 'struct.pack: ', repr(lockdata)
# the example from the library docs
f = open(filename, 'w')
@@ -44,7 +44,7 @@ if verbose:
if sys.platform not in ['os2emx']:
rv = fcntl.fcntl(f.fileno(), fcntl.F_SETLKW, lockdata)
if verbose:
- print 'String from fcntl with F_SETLKW: ', `rv`
+ print 'String from fcntl with F_SETLKW: ', repr(rv)
f.close()
os.unlink(filename)
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index c72fae7..0a76367 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -236,7 +236,7 @@ Guido's binary tree example.
... self.right = right
...
... def __repr__(self, level=0, indent=" "):
- ... s = level*indent + `self.label`
+ ... s = level*indent + repr(self.label)
... if self.left:
... s = s + "\\n" + self.left.__repr__(level+1, indent)
... if self.right:
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 6666c13..0eed4bb 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -47,7 +47,7 @@ if maxint == 2147483647:
try:
x = eval(s)
except OverflowError:
- print "OverflowError on huge integer literal " + `s`
+ print "OverflowError on huge integer literal " + repr(s)
elif eval('maxint == 9223372036854775807'):
if eval('-9223372036854775807-1 != -01000000000000000000000'):
raise TestFailed, 'max negative int'
@@ -58,7 +58,7 @@ elif eval('maxint == 9223372036854775807'):
try:
x = eval(s)
except OverflowError:
- print "OverflowError on huge integer literal " + `s`
+ print "OverflowError on huge integer literal " + repr(s)
else:
print 'Weird maxint value', maxint
diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py
index 90e80fc..3d6c9d1 100644
--- a/Lib/test/test_hash.py
+++ b/Lib/test/test_hash.py
@@ -14,7 +14,7 @@ class HashEqualityTestCase(unittest.TestCase):
hashed = map(hash, objlist)
for h in hashed[1:]:
if h != hashed[0]:
- self.fail("hashed values differ: %s" % `objlist`)
+ self.fail("hashed values differ: %r" % (objlist,))
def test_numeric_literals(self):
self.same_hash(1, 1L, 1.0, 1.0+0.0j)
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 3a6b7fc..a092265 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -91,8 +91,8 @@ testit('fmod(-10,1.5)', math.fmod(-10,1.5), -1)
print 'frexp'
def testfrexp(name, (mant, exp), (emant, eexp)):
if abs(mant-emant) > eps or exp != eexp:
- raise TestFailed, '%s returned %s, expected %s'%\
- (name, `mant, exp`, `emant,eexp`)
+ raise TestFailed, '%s returned %r, expected %r'%\
+ (name, (mant, exp), (emant,eexp))
testfrexp('frexp(-1)', math.frexp(-1), (-0.5, 1))
testfrexp('frexp(0)', math.frexp(0), (0, 0))
@@ -125,8 +125,8 @@ testit('log10(10)', math.log10(10), 1)
print 'modf'
def testmodf(name, (v1, v2), (e1, e2)):
if abs(v1-e1) > eps or abs(v2-e2):
- raise TestFailed, '%s returned %s, expected %s'%\
- (name, `v1,v2`, `e1,e2`)
+ raise TestFailed, '%s returned %r, expected %r'%\
+ (name, (v1,v2), (e1,e2))
testmodf('modf(1.5)', math.modf(1.5), (0.5, 1.0))
testmodf('modf(-1.5)', math.modf(-1.5), (-0.5, -1.0))
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index cb84987..a54fbd3 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1361,7 +1361,7 @@ for name in names:
print "Test Failed: ", name
sys.stdout.flush()
traceback.print_exception(*sys.exc_info())
- print `sys.exc_info()[1]`
+ print repr(sys.exc_info()[1])
Node.allnodes = {}
if failed:
diff --git a/Lib/test/test_mpz.py b/Lib/test/test_mpz.py
index dc583ae..be1fd1f 100644
--- a/Lib/test/test_mpz.py
+++ b/Lib/test/test_mpz.py
@@ -6,7 +6,7 @@ def check_conversion(num):
mpz_num = mpz.mpz(num)
vereq(int(mpz_num), num)
vereq(long(mpz_num), num)
- vereq(str(mpz_num), 'mpz(%s)' % `int(num)`)
+ vereq(str(mpz_num), 'mpz(%d)' % int(num))
check_conversion(10)
check_conversion(10L)
diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py
index ed1d736..2ecae69 100644
--- a/Lib/test/test_poll.py
+++ b/Lib/test/test_poll.py
@@ -157,7 +157,7 @@ def test_poll2():
elif flags & select.POLLIN:
line = p.readline()
if verbose:
- print `line`
+ print repr(line)
if not line:
if verbose:
print 'EOF'
diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py
index cf3a094..2a15a20 100644
--- a/Lib/test/test_popen2.py
+++ b/Lib/test/test_popen2.py
@@ -49,7 +49,7 @@ def _test():
w.close()
got = r.read()
if got.strip() != expected:
- raise ValueError("wrote %s read %s" % (`teststr`, `got`))
+ raise ValueError("wrote %r read %r" % (teststr, got))
print "testing popen3..."
try:
w, r, e = os.popen3([cmd])
@@ -59,10 +59,10 @@ def _test():
w.close()
got = r.read()
if got.strip() != expected:
- raise ValueError("wrote %s read %s" % (`teststr`, `got`))
+ raise ValueError("wrote %r read %r" % (teststr, got))
got = e.read()
if got:
- raise ValueError("unexected %s on stderr" % `got`)
+ raise ValueError("unexected %r on stderr" % (got,))
for inst in popen2._active[:]:
inst.wait()
if popen2._active:
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index a61bb66..27d6b52 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -40,14 +40,14 @@ class QueryTestCase(unittest.TestCase):
self.a, self.b):
# module-level convenience functions
verify(not pprint.isrecursive(safe),
- "expected not isrecursive for " + `safe`)
+ "expected not isrecursive for %r" % (safe,))
verify(pprint.isreadable(safe),
- "expected isreadable for " + `safe`)
+ "expected isreadable for %r" % (safe,))
# PrettyPrinter methods
verify(not pp.isrecursive(safe),
- "expected not isrecursive for " + `safe`)
+ "expected not isrecursive for %r" % (safe,))
verify(pp.isreadable(safe),
- "expected isreadable for " + `safe`)
+ "expected isreadable for %r" % (safe,))
def test_knotted(self):
# Verify .isrecursive() and .isreadable() w/ recursion
@@ -74,14 +74,14 @@ class QueryTestCase(unittest.TestCase):
for safe in self.a, self.b, self.d, (self.d, self.d):
# module-level convenience functions
verify(not pprint.isrecursive(safe),
- "expected not isrecursive for " + `safe`)
+ "expected not isrecursive for %r" % (safe,))
verify(pprint.isreadable(safe),
- "expected isreadable for " + `safe`)
+ "expected isreadable for %r" % (safe,))
# PrettyPrinter methods
verify(not pp.isrecursive(safe),
- "expected not isrecursive for " + `safe`)
+ "expected not isrecursive for %r" % (safe,))
verify(pp.isreadable(safe),
- "expected isreadable for " + `safe`)
+ "expected isreadable for %r" % (safe,))
def test_unreadable(self):
# Not recursive but not readable anyway
@@ -90,14 +90,14 @@ class QueryTestCase(unittest.TestCase):
for unreadable in type(3), pprint, pprint.isrecursive:
# module-level convenience functions
verify(not pprint.isrecursive(unreadable),
- "expected not isrecursive for " + `unreadable`)
+ "expected not isrecursive for %r" % (unreadable,))
verify(not pprint.isreadable(unreadable),
- "expected not isreadable for " + `unreadable`)
+ "expected not isreadable for %r" % (unreadable,))
# PrettyPrinter methods
verify(not pp.isrecursive(unreadable),
- "expected not isrecursive for " + `unreadable`)
+ "expected not isrecursive for %r" % (unreadable,))
verify(not pp.isreadable(unreadable),
- "expected not isreadable for " + `unreadable`)
+ "expected not isreadable for %r" % (unreadable,))
def test_same_as_repr(self):
# Simple objects, small containers and classes that overwrite __repr__
@@ -174,7 +174,7 @@ class DottedPrettyPrinter(pprint.PrettyPrinter):
def format(self, object, context, maxlevels, level):
if isinstance(object, str):
if ' ' in object:
- return `object`, 1, 0
+ return repr(object), 1, 0
else:
return object, 0, 0
else:
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index 7a1b7b1..6bf9072 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -19,7 +19,7 @@ def test_basic_pty():
debug("Calling master_open()")
master_fd, slave_name = pty.master_open()
debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name))
- debug("Calling slave_open(%s)"%`slave_name`)
+ debug("Calling slave_open(%r)"%(slave_name,))
slave_fd = pty.slave_open(slave_name)
debug("Got slave_fd '%d'"%slave_fd)
except OSError:
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py
index 09314c3..f281f8b 100644
--- a/Lib/test/test_pyexpat.py
+++ b/Lib/test/test_pyexpat.py
@@ -216,7 +216,7 @@ for entry in L:
if tag is not entry:
print "expected L to contain many references to the same string",
print "(it didn't)"
- print "L =", `L`
+ print "L =", repr(L)
break
# Tests of the buffer_text attribute.
@@ -228,8 +228,8 @@ class TextCollector:
def check(self, expected, label):
require(self.stuff == expected,
- "%s\nstuff = %s\nexpected = %s"
- % (label, `self.stuff`, `map(unicode, expected)`))
+ "%s\nstuff = %r\nexpected = %r"
+ % (label, self.stuff, map(unicode, expected)))
def CharacterDataHandler(self, text):
self.stuff.append(text)
diff --git a/Lib/test/test_repr.py b/Lib/test/test_repr.py
index 29e1687..48d969f 100644
--- a/Lib/test/test_repr.py
+++ b/Lib/test/test_repr.py
@@ -25,12 +25,12 @@ class ReprTests(unittest.TestCase):
eq(r("abcdefghijklmnop"),"'abcdefghijklmnop'")
s = "a"*30+"b"*30
- expected = `s`[:13] + "..." + `s`[-14:]
+ expected = repr(s)[:13] + "..." + repr(s)[-14:]
eq(r(s), expected)
eq(r("\"'"), repr("\"'"))
s = "\""*30+"'"*100
- expected = `s`[:13] + "..." + `s`[-14:]
+ expected = repr(s)[:13] + "..." + repr(s)[-14:]
eq(r(s), expected)
def test_container(self):
@@ -75,7 +75,7 @@ class ReprTests(unittest.TestCase):
eq(r(1.0/3), repr(1.0/3))
n = 10L**100
- expected = `n`[:18] + "..." + `n`[-19:]
+ expected = repr(n)[:18] + "..." + repr(n)[-19:]
eq(r(n), expected)
def test_instance(self):
@@ -84,7 +84,7 @@ class ReprTests(unittest.TestCase):
eq(r(i1), repr(i1))
i2 = ClassWithRepr("x"*1000)
- expected = `i2`[:13] + "..." + `i2`[-14:]
+ expected = repr(i2)[:13] + "..." + repr(i2)[-14:]
eq(r(i2), expected)
i3 = ClassWithFailingRepr()
diff --git a/Lib/test/test_rotor.py b/Lib/test/test_rotor.py
index eeec55a..16a7dcd 100644
--- a/Lib/test/test_rotor.py
+++ b/Lib/test/test_rotor.py
@@ -13,9 +13,9 @@ A = 'spam and eggs'
B = 'cheese shop'
a = r.encrypt(A)
-print `a`
+print repr(a)
b = r.encryptmore(B)
-print `b`
+print repr(b)
A1 = r.decrypt(a)
print A1
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
index 6a00fe4..eaec52b 100644
--- a/Lib/test/test_select.py
+++ b/Lib/test/test_select.py
@@ -57,7 +57,7 @@ def test():
if (rfd, wfd, xfd) == ([p], [], []):
line = p.readline()
if verbose:
- print `line`
+ print repr(line)
if not line:
if verbose:
print 'EOF'
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 3b108a1..3a85c76 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -426,7 +426,7 @@ class TestBasicOps(unittest.TestCase):
def test_repr(self):
if self.repr is not None:
- self.assertEqual(`self.set`, self.repr)
+ self.assertEqual(repr(self.set), self.repr)
def test_length(self):
self.assertEqual(len(self.set), self.length)
@@ -1076,7 +1076,7 @@ class TestCopying(unittest.TestCase):
def test_deep_copy(self):
dup = copy.deepcopy(self.set)
- ##print type(dup), `dup`
+ ##print type(dup), repr(dup)
dup_list = list(dup); dup_list.sort()
set_list = list(self.set); set_list.sort()
self.assertEqual(len(dup_list), len(set_list))
diff --git a/Lib/test/test_sets.py b/Lib/test/test_sets.py
index 9cc586f..4947e6b 100644
--- a/Lib/test/test_sets.py
+++ b/Lib/test/test_sets.py
@@ -12,7 +12,7 @@ class TestBasicOps(unittest.TestCase):
def test_repr(self):
if self.repr is not None:
- self.assertEqual(`self.set`, self.repr)
+ self.assertEqual(repr(self.set), self.repr)
def test_length(self):
self.assertEqual(len(self.set), self.length)
@@ -670,7 +670,7 @@ class TestCopying(unittest.TestCase):
def test_deep_copy(self):
dup = copy.deepcopy(self.set)
- ##print type(dup), `dup`
+ ##print type(dup), repr(dup)
dup_list = list(dup); dup_list.sort()
set_list = list(self.set); set_list.sort()
self.assertEqual(len(dup_list), len(set_list))
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 36396da..cee5593 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -43,7 +43,7 @@ def receive(sock, n, timeout=20):
if sock in r:
return sock.recv(n)
else:
- raise RuntimeError, "timed out on %s" % `sock`
+ raise RuntimeError, "timed out on %r" % (sock,)
def testdgram(proto, addr):
s = socket.socket(proto, socket.SOCK_DGRAM)
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 1e1092d..0641d9b 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -48,8 +48,8 @@ fmt3 = '3c3b18x12h6i6l6f3d'
sz = struct.calcsize(fmt)
sz3 = struct.calcsize(fmt3)
if sz * 3 != sz3:
- raise TestFailed, 'inconsistent sizes (3*%s -> 3*%d = %d, %s -> %d)' % (
- `fmt`, sz, 3*sz, `fmt3`, sz3)
+ raise TestFailed, 'inconsistent sizes (3*%r -> 3*%d = %d, %r -> %d)' % (
+ fmt, sz, 3*sz, fmt3, sz3)
simple_err(struct.pack, 'iii', 3)
simple_err(struct.pack, 'i', 3, 3, 3)
@@ -120,21 +120,21 @@ tests = [
for fmt, arg, big, lil, asy in tests:
if verbose:
- print `fmt`, `arg`, `big`, `lil`
+ print "%r %r %r %r" % (fmt, arg, big, lil)
for (xfmt, exp) in [('>'+fmt, big), ('!'+fmt, big), ('<'+fmt, lil),
('='+fmt, ISBIGENDIAN and big or lil)]:
res = struct.pack(xfmt, arg)
if res != exp:
- raise TestFailed, "pack(%s, %s) -> %s # expected %s" % (
- `fmt`, `arg`, `res`, `exp`)
+ raise TestFailed, "pack(%r, %r) -> %r # expected %r" % (
+ fmt, arg, res, exp)
n = struct.calcsize(xfmt)
if n != len(res):
- raise TestFailed, "calcsize(%s) -> %d # expected %d" % (
- `xfmt`, n, len(res))
+ raise TestFailed, "calcsize(%r) -> %d # expected %d" % (
+ xfmt, n, len(res))
rev = struct.unpack(xfmt, res)[0]
if rev != arg and not asy:
- raise TestFailed, "unpack(%s, %s) -> (%s,) # expected (%s,)" % (
- `fmt`, `res`, `rev`, `arg`)
+ raise TestFailed, "unpack(%r, %r) -> (%r,) # expected (%r,)" % (
+ fmt, res, rev, arg)
###########################################################################
# Simple native q/Q tests.
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index a40190e..4838608 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -18,7 +18,7 @@ class SyntaxTestCase(unittest.TestCase):
except SyntaxError, err:
mo = re.search(errtext, str(err))
if mo is None:
- self.fail("SyntaxError did not contain '%s'" % `errtext`)
+ self.fail("SyntaxError did not contain '%r'" % (errtext,))
else:
self.fail("compile() did not raise SyntaxError")
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 1dd5165..aa8f854 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -386,9 +386,9 @@ for copymode in -1, +1:
a = {}
b = {}
for i in range(size):
- a[`i`] = i
+ a[repr(i)] = i
if copymode < 0:
- b[`i`] = i
+ b[repr(i)] = i
if copymode > 0:
b = a.copy()
for i in range(size):
diff --git a/Lib/test/test_univnewlines.py b/Lib/test/test_univnewlines.py
index a6c079b..e91bde7 100644
--- a/Lib/test/test_univnewlines.py
+++ b/Lib/test/test_univnewlines.py
@@ -51,13 +51,13 @@ class TestGenericUnivNewlines(unittest.TestCase):
fp = open(test_support.TESTFN, self.READMODE)
data = fp.read()
self.assertEqual(data, DATA_LF)
- self.assertEqual(`fp.newlines`, `self.NEWLINE`)
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readlines(self):
fp = open(test_support.TESTFN, self.READMODE)
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
- self.assertEqual(`fp.newlines`, `self.NEWLINE`)
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readline(self):
fp = open(test_support.TESTFN, self.READMODE)
@@ -67,7 +67,7 @@ class TestGenericUnivNewlines(unittest.TestCase):
data.append(d)
d = fp.readline()
self.assertEqual(data, DATA_SPLIT)
- self.assertEqual(`fp.newlines`, `self.NEWLINE`)
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_seek(self):
fp = open(test_support.TESTFN, self.READMODE)
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 00cd7ae..b2d266d 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -176,7 +176,7 @@ class ReferencesTestCase(TestBase):
L2 = UserList.UserList(L)
p2 = weakref.proxy(L2)
self.assertEqual(p, p2)
- ## self.assertEqual(`L2`, `p2`)
+ ## self.assertEqual(repr(L2), repr(p2))
L3 = UserList.UserList(range(10))
p3 = weakref.proxy(L3)
self.assertEqual(L3[:], p3[:])