summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_long.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-12-23 15:36:42 (GMT)
committerFred Drake <fdrake@acm.org>1999-12-23 15:36:42 (GMT)
commitdb1bd5c230e2ed71b95939e61a09271887b03b31 (patch)
treed663825929482bb9f166b49900bd7e0a78a4d72c /Lib/test/test_long.py
parentb06007a3ba0dcc3bfdc50131a0729dd21882a4ea (diff)
downloadcpython-db1bd5c230e2ed71b95939e61a09271887b03b31.zip
cpython-db1bd5c230e2ed71b95939e61a09271887b03b31.tar.gz
cpython-db1bd5c230e2ed71b95939e61a09271887b03b31.tar.bz2
Revise tests to support str(<long int object>) not appending "L".
Diffstat (limited to 'Lib/test/test_long.py')
-rw-r--r--Lib/test/test_long.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index f235d9c..25abcc8 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -159,7 +159,7 @@ def test_bitop_identities(maxdigits=MAXDIGITS):
test_bitop_identities_2(x, y)
test_bitop_identities_3(x, y, getran((lenx + leny)/2))
-# ------------------------------------------------------ hex oct str atol
+# ------------------------------------------------- hex oct repr str atol
def slow_format(x, base):
if (x, base) == (0, 8):
@@ -181,12 +181,18 @@ def slow_format(x, base):
def test_format_1(x):
from string import atol
- for base, mapper in (8, oct), (10, str), (16, hex):
+ for base, mapper in (8, oct), (10, repr), (16, hex):
got = mapper(x)
expected = slow_format(x, base)
check(got == expected, mapper.__name__, "returned",
got, "but expected", expected, "for", x)
check(atol(got, 0) == x, 'atol("%s", 0) !=' % got, x)
+ # str() has to be checked a little differently since there's no
+ # trailing "L"
+ got = str(x)
+ expected = slow_format(x, 10)[:-1]
+ check(got == expected, mapper.__name__, "returned",
+ got, "but expected", expected, "for", x)
def test_format(maxdigits=MAXDIGITS):
print "long str/hex/oct/atol"