diff options
Diffstat (limited to 'Lib/dos-8x3/test_lon.py')
-rw-r--r-- | Lib/dos-8x3/test_lon.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/dos-8x3/test_lon.py b/Lib/dos-8x3/test_lon.py index f235d9c..6a1f117 100644 --- a/Lib/dos-8x3/test_lon.py +++ b/Lib/dos-8x3/test_lon.py @@ -77,6 +77,8 @@ def getran2(ndigits): def test_division_2(x, y): q, r = divmod(x, y) q2, r2 = x/y, x%y + pab, pba = x*y, y*x + check(pab == pba, "multiplication does not commute for", x, y) check(q == q2, "divmod returns different quotient than / for", x, y) check(r == r2, "divmod returns different mod than % for", x, y) check(x == q*y + r, "x != q*y + r after divmod on", x, y) @@ -159,7 +161,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 +183,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" |