diff options
author | Guido van Rossum <guido@python.org> | 2001-09-04 19:14:14 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-09-04 19:14:14 (GMT) |
commit | 54e54c6877329e105406c48490f218faff59db39 (patch) | |
tree | 6bbdf1f6efaa2253af424f59dc9564a5458d6739 /Lib/test | |
parent | b8f22749853cf79bfbe3709309e67d1a448f4cab (diff) | |
download | cpython-54e54c6877329e105406c48490f218faff59db39.zip cpython-54e54c6877329e105406c48490f218faff59db39.tar.gz cpython-54e54c6877329e105406c48490f218faff59db39.tar.bz2 |
The first batch of changes recommended by the fixdiv tool. These are
mostly changes of / operators into //. Once or twice I did more or
less than recommended.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_audioop.py | 4 | ||||
-rw-r--r-- | Lib/test/test_augassign.py | 6 | ||||
-rw-r--r-- | Lib/test/test_b1.py | 2 | ||||
-rwxr-xr-x | Lib/test/test_binascii.py | 4 | ||||
-rw-r--r-- | Lib/test/test_binop.py | 4 | ||||
-rw-r--r-- | Lib/test/test_compare.py | 2 | ||||
-rw-r--r-- | Lib/test/test_long.py | 10 | ||||
-rw-r--r-- | Lib/test/test_operator.py | 2 | ||||
-rw-r--r-- | Lib/test/test_pty.py | 2 | ||||
-rwxr-xr-x | Lib/test/test_strftime.py | 4 |
10 files changed, 20 insertions, 20 deletions
diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py index 495a918..a4e1914 100644 --- a/Lib/test/test_audioop.py +++ b/Lib/test/test_audioop.py @@ -116,8 +116,8 @@ def testlin2lin(data): # too simple: we test only the size for d1 in data: for d2 in data: - got = len(d1)/3 - wtd = len(d2)/3 + got = len(d1)//3 + wtd = len(d2)//3 if len(audioop.lin2lin(d1, got, wtd)) != len(d2): return 0 return 1 diff --git a/Lib/test/test_augassign.py b/Lib/test/test_augassign.py index e9e5b23..c372b9a 100644 --- a/Lib/test/test_augassign.py +++ b/Lib/test/test_augassign.py @@ -5,7 +5,7 @@ x += 1 x *= 2 x **= 2 x -= 8 -x /= 2 +x //= 2 x //= 1 x %= 12 x &= 2 @@ -19,7 +19,7 @@ x[0] += 1 x[0] *= 2 x[0] **= 2 x[0] -= 8 -x[0] /= 2 +x[0] //= 2 x[0] //= 2 x[0] %= 12 x[0] &= 2 @@ -33,7 +33,7 @@ x[0] += 1 x[0] *= 2 x[0] **= 2 x[0] -= 8 -x[0] /= 2 +x[0] //= 2 x[0] //= 1 x[0] %= 12 x[0] &= 2 diff --git a/Lib/test/test_b1.py b/Lib/test/test_b1.py index 46a6da0..978f674 100644 --- a/Lib/test/test_b1.py +++ b/Lib/test/test_b1.py @@ -413,7 +413,7 @@ else: # Worked by accident in Windows release build, but failed in debug build. # Failed in all Linux builds. x = -1-sys.maxint -if x >> 1 != x/2: +if x >> 1 != x//2: raise TestFailed("x >> 1 != x/2 when x == -1-sys.maxint") print 'isinstance' diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index f03fc55..cc78ee3 100755 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -54,10 +54,10 @@ for i in range(256): fillers = fillers + c def addnoise(line): noise = fillers - ratio = len(line) / len(noise) + ratio = len(line) // len(noise) res = "" while line and noise: - if len(line) / len(noise) > ratio: + if len(line) // len(noise) > ratio: c, line = line[0], line[1:] else: c, noise = noise[0], noise[1:] diff --git a/Lib/test/test_binop.py b/Lib/test/test_binop.py index f1e654a..7eded9a 100644 --- a/Lib/test/test_binop.py +++ b/Lib/test/test_binop.py @@ -42,8 +42,8 @@ class Rat(object): if den == 0: raise ZeroDivisionError, "zero denominator" g = gcd(den, num) - self.__num = long(num/g) - self.__den = long(den/g) + self.__num = long(num//g) + self.__den = long(den//g) def _get_num(self): """Accessor function for read-only 'num' attribute of Rat.""" diff --git a/Lib/test/test_compare.py b/Lib/test/test_compare.py index bc833ea..8100aec 100644 --- a/Lib/test/test_compare.py +++ b/Lib/test/test_compare.py @@ -47,7 +47,7 @@ def test(): # Ensure default comparison compares id() of args L = [] for i in range(10): - L.insert(len(L)/2, Empty()) + L.insert(len(L)//2, Empty()) for a in L: for b in L: if cmp(a, b) != cmp(id(a), id(b)): diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index e123638..01d567a 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -76,7 +76,7 @@ def getran2(ndigits): def test_division_2(x, y): q, r = divmod(x, y) - q2, r2 = x/y, 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) @@ -117,7 +117,7 @@ def test_bitop_identities_1(x): for n in range(2*SHIFT): p2 = 2L ** n check(x << n >> n == x, "x << n >> n != x for", x, n) - check(x / p2 == x >> n, "x / p2 != x >> n for x n p2", x, n, p2) + check(x // p2 == x >> n, "x // p2 != x >> n for x n p2", x, n, p2) check(x * p2 == x << n, "x * p2 != x << n for x n p2", x, n, p2) check(x & -p2 == x >> n << n == x & ~(p2 - 1), "not x & -p2 == x >> n << n == x & ~(p2 - 1) for x n p2", @@ -161,7 +161,7 @@ def test_bitop_identities(maxdigits=MAXDIGITS): for leny in digits: y = getran(leny) test_bitop_identities_2(x, y) - test_bitop_identities_3(x, y, getran((lenx + leny)/2)) + test_bitop_identities_3(x, y, getran((lenx + leny)//2)) # ------------------------------------------------- hex oct repr str atol @@ -296,8 +296,8 @@ def test_auto_overflow(): checkit(x, '*', y) if y: - expected = longx / longy - got = x / y + expected = longx // longy + got = x // y checkit(x, '/', y) expected = longx // longy diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py index 939c995..6312d9a 100644 --- a/Lib/test/test_operator.py +++ b/Lib/test/test_operator.py @@ -82,7 +82,7 @@ class OperatorTestCase(unittest.TestCase): self.assert_(a == [0, 1, 8, 9]) def test_div(self): - self.failUnless(operator.div(5, 2) == 2) + self.failUnless(operator.floordiv(5, 2) == 2) def test_floordiv(self): self.failUnless(operator.floordiv(5, 2) == 2) diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index b119f62..7d72b76 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -86,7 +86,7 @@ if pid == pty.CHILD: else: debug("Waiting for child (%d) to finish."%pid) (pid, status) = os.waitpid(pid, 0) - res = status / 256 + res = status >> 8 debug("Child (%d) exited with status %d (%d)."%(pid, res, status)) if res == 1: raise TestFailed, "Child raised an unexpected exception in os.setsid()" diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py index 47f35f5..4ce72b9 100755 --- a/Lib/test/test_strftime.py +++ b/Lib/test/test_strftime.py @@ -64,10 +64,10 @@ def strftest(now): ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), - ('%U', '%02d' % ((now[7] + jan1[6])/7), + ('%U', '%02d' % ((now[7] + jan1[6])//7), 'week number of the year (Sun 1st)'), ('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), - ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7), + ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)//7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), |