diff options
author | Georg Brandl <georg@python.org> | 2009-08-13 08:51:18 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-08-13 08:51:18 (GMT) |
commit | ab91fdef1f1e556203a2eee98ba7d379e4790de9 (patch) | |
tree | 6f8f00dc18cc5f2801a675df277c2c595eb85ec8 /Lib/test/test_long.py | |
parent | ef82be368abdea8e8032500e7ecc3a22f5f07851 (diff) | |
download | cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.zip cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.tar.gz cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.tar.bz2 |
Merged revisions 73715 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r73715 | benjamin.peterson | 2009-07-01 01:06:06 +0200 (Mi, 01 Jul 2009) | 1 line
convert old fail* assertions to assert*
........
Diffstat (limited to 'Lib/test/test_long.py')
-rw-r--r-- | Lib/test/test_long.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 53d3e6b..1b5e6d4 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -65,7 +65,7 @@ class LongTest(unittest.TestCase): # The sign of the number is also random. def getran(self, ndigits): - self.assert_(ndigits > 0) + self.assertTrue(ndigits > 0) nbits_hi = ndigits * SHIFT nbits_lo = nbits_hi - SHIFT + 1 answer = 0 @@ -74,13 +74,13 @@ class LongTest(unittest.TestCase): while nbits < nbits_lo: bits = (r >> 1) + 1 bits = min(bits, nbits_hi - nbits) - self.assert_(1 <= bits <= SHIFT) + self.assertTrue(1 <= bits <= SHIFT) nbits = nbits + bits answer = answer << bits if r & 1: answer = answer | ((1 << bits) - 1) r = int(random.random() * (SHIFT * 2)) - self.assert_(nbits_lo <= nbits <= nbits_hi) + self.assertTrue(nbits_lo <= nbits <= nbits_hi) if random.random() < 0.5: answer = -answer return answer @@ -106,9 +106,9 @@ class LongTest(unittest.TestCase): eq(r, r2, Frm("divmod returns different mod than %% for %r and %r", x, y)) eq(x, q*y + r, Frm("x != q*y + r after divmod on x=%r, y=%r", x, y)) if y > 0: - self.assert_(0 <= r < y, Frm("bad mod from divmod on %r and %r", x, y)) + self.assertTrue(0 <= r < y, Frm("bad mod from divmod on %r and %r", x, y)) else: - self.assert_(y < r <= 0, Frm("bad mod from divmod on %r and %r", x, y)) + self.assertTrue(y < r <= 0, Frm("bad mod from divmod on %r and %r", x, y)) def test_division(self): digits = list(range(1, MAXDIGITS+1)) + list(range(KARATSUBA_CUTOFF, @@ -538,7 +538,7 @@ class LongTest(unittest.TestCase): y = int(x) except OverflowError: self.fail("int(long(sys.maxsize) + 1) mustn't overflow") - self.assert_(isinstance(y, int), + self.assertTrue(isinstance(y, int), "int(long(sys.maxsize) + 1) should have returned long") x = hugeneg_aslong - 1 @@ -546,14 +546,14 @@ class LongTest(unittest.TestCase): y = int(x) except OverflowError: self.fail("int(long(-sys.maxsize-1) - 1) mustn't overflow") - self.assert_(isinstance(y, int), + self.assertTrue(isinstance(y, int), "int(long(-sys.maxsize-1) - 1) should have returned long") class long2(int): pass x = long2(1<<100) y = int(x) - self.assert_(type(y) is int, + self.assertTrue(type(y) is int, "overflowing int conversion must return long not long subtype") # ----------------------------------- tests of auto int->long conversion @@ -958,7 +958,7 @@ class LongTest(unittest.TestCase): self.assertEqual(k, len(bin(x).lstrip('-0b'))) # Behaviour as specified in the docs if x != 0: - self.assert_(2**(k-1) <= abs(x) < 2**k) + self.assertTrue(2**(k-1) <= abs(x) < 2**k) else: self.assertEqual(k, 0) # Alternative definition: x.bit_length() == 1 + floor(log_2(x)) @@ -995,7 +995,7 @@ class LongTest(unittest.TestCase): got = round(k+offset, -1) expected = v+offset self.assertEqual(got, expected) - self.assert_(type(got) is int) + self.assertTrue(type(got) is int) # larger second argument self.assertEqual(round(-150, -2), -200) @@ -1034,7 +1034,7 @@ class LongTest(unittest.TestCase): got = round(10**k + 324678, -3) expect = 10**k + 325000 self.assertEqual(got, expect) - self.assert_(type(got) is int) + self.assertTrue(type(got) is int) # nonnegative second argument: round(x, n) should just return x for n in range(5): @@ -1042,7 +1042,7 @@ class LongTest(unittest.TestCase): x = random.randrange(-10000, 10000) got = round(x, n) self.assertEqual(got, x) - self.assert_(type(got) is int) + self.assertTrue(type(got) is int) for huge_n in 2**31-1, 2**31, 2**63-1, 2**63, 2**100, 10**100: self.assertEqual(round(8979323, huge_n), 8979323) @@ -1051,7 +1051,7 @@ class LongTest(unittest.TestCase): x = random.randrange(-10000, 10000) got = round(x) self.assertEqual(got, x) - self.assert_(type(got) is int) + self.assertTrue(type(got) is int) # bad second argument bad_exponents = ('brian', 2.0, 0j, None) |