diff options
author | Fred Drake <fdrake@acm.org> | 2000-12-12 23:11:42 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-12-12 23:11:42 (GMT) |
commit | 132dce22469f476f399d1bbc6d1cc2f7ba0110cc (patch) | |
tree | 4b0988e41b3b7d25d10c2a24fb18b07ff376f66d /Lib/test | |
parent | 63596aeb33c2837d7802449c8906349c9ea1998e (diff) | |
download | cpython-132dce22469f476f399d1bbc6d1cc2f7ba0110cc.zip cpython-132dce22469f476f399d1bbc6d1cc2f7ba0110cc.tar.gz cpython-132dce22469f476f399d1bbc6d1cc2f7ba0110cc.tar.bz2 |
Update the code to better reflect recommended style:
Use != instead of <> since <> is documented as "obsolescent".
Use "is" and "is not" when comparing with None or type objects.
Diffstat (limited to 'Lib/test')
-rwxr-xr-x | Lib/test/regrtest.py | 2 | ||||
-rw-r--r-- | Lib/test/test_audioop.py | 92 | ||||
-rw-r--r-- | Lib/test/test_b1.py | 254 | ||||
-rw-r--r-- | Lib/test/test_b2.py | 196 | ||||
-rwxr-xr-x | Lib/test/test_binascii.py | 2 | ||||
-rwxr-xr-x | Lib/test/test_binhex.py | 4 | ||||
-rwxr-xr-x | Lib/test/test_bsddb.py | 4 | ||||
-rw-r--r-- | Lib/test/test_grammar.py | 20 | ||||
-rw-r--r-- | Lib/test/test_math.py | 2 | ||||
-rw-r--r-- | Lib/test/test_md5.py | 2 | ||||
-rw-r--r-- | Lib/test/test_mmap.py | 2 | ||||
-rw-r--r-- | Lib/test/test_new.py | 6 | ||||
-rw-r--r-- | Lib/test/test_nis.py | 2 | ||||
-rw-r--r-- | Lib/test/test_opcodes.py | 2 | ||||
-rw-r--r-- | Lib/test/test_operator.py | 10 | ||||
-rw-r--r-- | Lib/test/test_pow.py | 4 | ||||
-rw-r--r-- | Lib/test/test_pty.py | 2 | ||||
-rw-r--r-- | Lib/test/test_pwd.py | 4 | ||||
-rw-r--r-- | Lib/test/test_re.py | 22 | ||||
-rw-r--r-- | Lib/test/test_rotor.py | 4 | ||||
-rw-r--r-- | Lib/test/test_sax.py | 10 | ||||
-rw-r--r-- | Lib/test/test_socket.py | 2 | ||||
-rw-r--r-- | Lib/test/test_sre.py | 16 | ||||
-rw-r--r-- | Lib/test/test_struct.py | 8 | ||||
-rw-r--r-- | Lib/test/test_support.py | 2 | ||||
-rw-r--r-- | Lib/test/test_time.py | 8 | ||||
-rw-r--r-- | Lib/test/test_types.py | 150 | ||||
-rw-r--r-- | Lib/test/test_unpack.py | 14 |
28 files changed, 423 insertions, 423 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 3d9c5af..dadf69b 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -283,7 +283,7 @@ class Compare: def write(self, data): expected = self.fp.read(len(data)) - if data <> expected: + if data != expected: raise test_support.TestFailed, \ 'Writing: '+`data`+', expected: '+`expected` diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py index 900ec58..495a918 100644 --- a/Lib/test/test_audioop.py +++ b/Lib/test/test_audioop.py @@ -24,61 +24,61 @@ def gendata4(): def testmax(data): if verbose: print 'max' - if audioop.max(data[0], 1) <> 2 or \ - audioop.max(data[1], 2) <> 2 or \ - audioop.max(data[2], 4) <> 2: + if audioop.max(data[0], 1) != 2 or \ + audioop.max(data[1], 2) != 2 or \ + audioop.max(data[2], 4) != 2: return 0 return 1 def testminmax(data): if verbose: print 'minmax' - if audioop.minmax(data[0], 1) <> (0, 2) or \ - audioop.minmax(data[1], 2) <> (0, 2) or \ - audioop.minmax(data[2], 4) <> (0, 2): + if audioop.minmax(data[0], 1) != (0, 2) or \ + audioop.minmax(data[1], 2) != (0, 2) or \ + audioop.minmax(data[2], 4) != (0, 2): return 0 return 1 def testmaxpp(data): if verbose: print 'maxpp' - if audioop.maxpp(data[0], 1) <> 0 or \ - audioop.maxpp(data[1], 2) <> 0 or \ - audioop.maxpp(data[2], 4) <> 0: + if audioop.maxpp(data[0], 1) != 0 or \ + audioop.maxpp(data[1], 2) != 0 or \ + audioop.maxpp(data[2], 4) != 0: return 0 return 1 def testavg(data): if verbose: print 'avg' - if audioop.avg(data[0], 1) <> 1 or \ - audioop.avg(data[1], 2) <> 1 or \ - audioop.avg(data[2], 4) <> 1: + if audioop.avg(data[0], 1) != 1 or \ + audioop.avg(data[1], 2) != 1 or \ + audioop.avg(data[2], 4) != 1: return 0 return 1 def testavgpp(data): if verbose: print 'avgpp' - if audioop.avgpp(data[0], 1) <> 0 or \ - audioop.avgpp(data[1], 2) <> 0 or \ - audioop.avgpp(data[2], 4) <> 0: + if audioop.avgpp(data[0], 1) != 0 or \ + audioop.avgpp(data[1], 2) != 0 or \ + audioop.avgpp(data[2], 4) != 0: return 0 return 1 def testrms(data): - if audioop.rms(data[0], 1) <> 1 or \ - audioop.rms(data[1], 2) <> 1 or \ - audioop.rms(data[2], 4) <> 1: + if audioop.rms(data[0], 1) != 1 or \ + audioop.rms(data[1], 2) != 1 or \ + audioop.rms(data[2], 4) != 1: return 0 return 1 def testcross(data): if verbose: print 'cross' - if audioop.cross(data[0], 1) <> 0 or \ - audioop.cross(data[1], 2) <> 0 or \ - audioop.cross(data[2], 4) <> 0: + if audioop.cross(data[0], 1) != 0 or \ + audioop.cross(data[1], 2) != 0 or \ + audioop.cross(data[2], 4) != 0: return 0 return 1 @@ -91,9 +91,9 @@ def testadd(data): for s in d: str = str + chr(ord(s)*2) data2.append(str) - if audioop.add(data[0], data[0], 1) <> data2[0] or \ - audioop.add(data[1], data[1], 2) <> data2[1] or \ - audioop.add(data[2], data[2], 4) <> data2[2]: + if audioop.add(data[0], data[0], 1) != data2[0] or \ + audioop.add(data[1], data[1], 2) != data2[1] or \ + audioop.add(data[2], data[2], 4) != data2[2]: return 0 return 1 @@ -104,9 +104,9 @@ def testbias(data): d1 = audioop.bias(data[0], 1, 100) d2 = audioop.bias(data[1], 2, 100) d4 = audioop.bias(data[2], 4, 100) - if audioop.avg(d1, 1) <> 101 or \ - audioop.avg(d2, 2) <> 101 or \ - audioop.avg(d4, 4) <> 101: + if audioop.avg(d1, 1) != 101 or \ + audioop.avg(d2, 2) != 101 or \ + audioop.avg(d4, 4) != 101: return 0 return 1 @@ -118,13 +118,13 @@ def testlin2lin(data): for d2 in data: got = len(d1)/3 wtd = len(d2)/3 - if len(audioop.lin2lin(d1, got, wtd)) <> len(d2): + if len(audioop.lin2lin(d1, got, wtd)) != len(d2): return 0 return 1 def testadpcm2lin(data): # Very cursory test - if audioop.adpcm2lin('\0\0', 1, None) <> ('\0\0\0\0', (0,0)): + if audioop.adpcm2lin('\0\0', 1, None) != ('\0\0\0\0', (0,0)): return 0 return 1 @@ -132,16 +132,16 @@ def testlin2adpcm(data): if verbose: print 'lin2adpcm' # Very cursory test - if audioop.lin2adpcm('\0\0\0\0', 1, None) <> ('\0\0', (0,0)): + if audioop.lin2adpcm('\0\0\0\0', 1, None) != ('\0\0', (0,0)): return 0 return 1 def testlin2ulaw(data): if verbose: print 'lin2ulaw' - if audioop.lin2ulaw(data[0], 1) <> '\377\347\333' or \ - audioop.lin2ulaw(data[1], 2) <> '\377\377\377' or \ - audioop.lin2ulaw(data[2], 4) <> '\377\377\377': + if audioop.lin2ulaw(data[0], 1) != '\377\347\333' or \ + audioop.lin2ulaw(data[1], 2) != '\377\377\377' or \ + audioop.lin2ulaw(data[2], 4) != '\377\377\377': return 0 return 1 @@ -150,7 +150,7 @@ def testulaw2lin(data): print 'ulaw2lin' # Cursory d = audioop.lin2ulaw(data[0], 1) - if audioop.ulaw2lin(d, 1) <> data[0]: + if audioop.ulaw2lin(d, 1) != data[0]: return 0 return 1 @@ -163,9 +163,9 @@ def testmul(data): for s in d: str = str + chr(ord(s)*2) data2.append(str) - if audioop.mul(data[0], 1, 2) <> data2[0] or \ - audioop.mul(data[1],2, 2) <> data2[1] or \ - audioop.mul(data[2], 4, 2) <> data2[2]: + if audioop.mul(data[0], 1, 2) != data2[0] or \ + audioop.mul(data[1],2, 2) != data2[1] or \ + audioop.mul(data[2], 4, 2) != data2[2]: return 0 return 1 @@ -182,7 +182,7 @@ def testratecv(data): def testreverse(data): if verbose: print 'reverse' - if audioop.reverse(data[0], 1) <> '\2\1\0': + if audioop.reverse(data[0], 1) != '\2\1\0': return 0 return 1 @@ -192,7 +192,7 @@ def testtomono(data): data2 = '' for d in data[0]: data2 = data2 + d + d - if audioop.tomono(data2, 1, 0.5, 0.5) <> data[0]: + if audioop.tomono(data2, 1, 0.5, 0.5) != data[0]: return 0 return 1 @@ -202,28 +202,28 @@ def testtostereo(data): data2 = '' for d in data[0]: data2 = data2 + d + d - if audioop.tostereo(data[0], 1, 1, 1) <> data2: + if audioop.tostereo(data[0], 1, 1, 1) != data2: return 0 return 1 def testfindfactor(data): if verbose: print 'findfactor' - if audioop.findfactor(data[1], data[1]) <> 1.0: + if audioop.findfactor(data[1], data[1]) != 1.0: return 0 return 1 def testfindfit(data): if verbose: print 'findfit' - if audioop.findfit(data[1], data[1]) <> (0, 1.0): + if audioop.findfit(data[1], data[1]) != (0, 1.0): return 0 return 1 def testfindmax(data): if verbose: print 'findmax' - if audioop.findmax(data[1], 1) <> 2: + if audioop.findmax(data[1], 1) != 2: return 0 return 1 @@ -231,9 +231,9 @@ def testgetsample(data): if verbose: print 'getsample' for i in range(3): - if audioop.getsample(data[0], 1, i) <> i or \ - audioop.getsample(data[1], 2, i) <> i or \ - audioop.getsample(data[2], 4, i) <> i: + if audioop.getsample(data[0], 1, i) != i or \ + audioop.getsample(data[1], 2, i) != i or \ + audioop.getsample(data[2], 4, i) != i: return 0 return 1 diff --git a/Lib/test/test_b1.py b/Lib/test/test_b1.py index 24c5279..8adcbef 100644 --- a/Lib/test/test_b1.py +++ b/Lib/test/test_b1.py @@ -11,17 +11,17 @@ except ImportError: pass else: raise TestFailed, "__import__('spamspam') should fail" print 'abs' -if abs(0) <> 0: raise TestFailed, 'abs(0)' -if abs(1234) <> 1234: raise TestFailed, 'abs(1234)' -if abs(-1234) <> 1234: raise TestFailed, 'abs(-1234)' +if abs(0) != 0: raise TestFailed, 'abs(0)' +if abs(1234) != 1234: raise TestFailed, 'abs(1234)' +if abs(-1234) != 1234: raise TestFailed, 'abs(-1234)' # -if abs(0.0) <> 0.0: raise TestFailed, 'abs(0.0)' -if abs(3.14) <> 3.14: raise TestFailed, 'abs(3.14)' -if abs(-3.14) <> 3.14: raise TestFailed, 'abs(-3.14)' +if abs(0.0) != 0.0: raise TestFailed, 'abs(0.0)' +if abs(3.14) != 3.14: raise TestFailed, 'abs(3.14)' +if abs(-3.14) != 3.14: raise TestFailed, 'abs(-3.14)' # -if abs(0L) <> 0L: raise TestFailed, 'abs(0L)' -if abs(1234L) <> 1234L: raise TestFailed, 'abs(1234L)' -if abs(-1234L) <> 1234L: raise TestFailed, 'abs(-1234L)' +if abs(0L) != 0L: raise TestFailed, 'abs(0L)' +if abs(1234L) != 1234L: raise TestFailed, 'abs(1234L)' +if abs(-1234L) != 1234L: raise TestFailed, 'abs(-1234L)' print 'apply' def f0(*args): @@ -55,14 +55,14 @@ y = D() if not callable(y): raise TestFailed, 'callable(y)' print 'chr' -if chr(32) <> ' ': raise TestFailed, 'chr(32)' -if chr(65) <> 'A': raise TestFailed, 'chr(65)' -if chr(97) <> 'a': raise TestFailed, 'chr(97)' +if chr(32) != ' ': raise TestFailed, 'chr(32)' +if chr(65) != 'A': raise TestFailed, 'chr(65)' +if chr(97) != 'a': raise TestFailed, 'chr(97)' print 'cmp' -if cmp(-1, 1) <> -1: raise TestFailed, 'cmp(-1, 1)' -if cmp(1, -1) <> 1: raise TestFailed, 'cmp(1, -1)' -if cmp(1, 1) <> 0: raise TestFailed, 'cmp(1, 1)' +if cmp(-1, 1) != -1: raise TestFailed, 'cmp(-1, 1)' +if cmp(1, -1) != 1: raise TestFailed, 'cmp(1, -1)' +if cmp(1, 1) != 0: raise TestFailed, 'cmp(1, 1)' # verify that circular objects are handled a = []; a.append(a) b = []; b.append(b) @@ -77,40 +77,40 @@ a.pop(); b.pop(); c.pop() print 'coerce' if fcmp(coerce(1, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1, 1.1)' -if coerce(1, 1L) <> (1L, 1L): raise TestFailed, 'coerce(1, 1L)' +if coerce(1, 1L) != (1L, 1L): raise TestFailed, 'coerce(1, 1L)' if fcmp(coerce(1L, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1L, 1.1)' print 'compile' compile('print 1\n', '', 'exec') print 'complex' -if complex(1,10) <> 1+10j: raise TestFailed, 'complex(1,10)' -if complex(1,10L) <> 1+10j: raise TestFailed, 'complex(1,10L)' -if complex(1,10.0) <> 1+10j: raise TestFailed, 'complex(1,10.0)' -if complex(1L,10) <> 1+10j: raise TestFailed, 'complex(1L,10)' -if complex(1L,10L) <> 1+10j: raise TestFailed, 'complex(1L,10L)' -if complex(1L,10.0) <> 1+10j: raise TestFailed, 'complex(1L,10.0)' -if complex(1.0,10) <> 1+10j: raise TestFailed, 'complex(1.0,10)' -if complex(1.0,10L) <> 1+10j: raise TestFailed, 'complex(1.0,10L)' -if complex(1.0,10.0) <> 1+10j: raise TestFailed, 'complex(1.0,10.0)' -if complex(3.14+0j) <> 3.14+0j: raise TestFailed, 'complex(3.14)' -if complex(3.14) <> 3.14+0j: raise TestFailed, 'complex(3.14)' -if complex(314) <> 314.0+0j: raise TestFailed, 'complex(314)' -if complex(314L) <> 314.0+0j: raise TestFailed, 'complex(314L)' -if complex(3.14+0j, 0j) <> 3.14+0j: raise TestFailed, 'complex(3.14, 0j)' -if complex(3.14, 0.0) <> 3.14+0j: raise TestFailed, 'complex(3.14, 0.0)' -if complex(314, 0) <> 314.0+0j: raise TestFailed, 'complex(314, 0)' -if complex(314L, 0L) <> 314.0+0j: raise TestFailed, 'complex(314L, 0L)' -if complex(0j, 3.14j) <> -3.14+0j: raise TestFailed, 'complex(0j, 3.14j)' -if complex(0.0, 3.14j) <> -3.14+0j: raise TestFailed, 'complex(0.0, 3.14j)' -if complex(0j, 3.14) <> 3.14j: raise TestFailed, 'complex(0j, 3.14)' -if complex(0.0, 3.14) <> 3.14j: raise TestFailed, 'complex(0.0, 3.14)' -if complex(" 3.14+J ") <> 3.14+1j: raise TestFailed, 'complex(" 3.14+J )"' -if complex(u" 3.14+J ") <> 3.14+1j: raise TestFailed, 'complex(u" 3.14+J )"' +if complex(1,10) != 1+10j: raise TestFailed, 'complex(1,10)' +if complex(1,10L) != 1+10j: raise TestFailed, 'complex(1,10L)' +if complex(1,10.0) != 1+10j: raise TestFailed, 'complex(1,10.0)' +if complex(1L,10) != 1+10j: raise TestFailed, 'complex(1L,10)' +if complex(1L,10L) != 1+10j: raise TestFailed, 'complex(1L,10L)' +if complex(1L,10.0) != 1+10j: raise TestFailed, 'complex(1L,10.0)' +if complex(1.0,10) != 1+10j: raise TestFailed, 'complex(1.0,10)' +if complex(1.0,10L) != 1+10j: raise TestFailed, 'complex(1.0,10L)' +if complex(1.0,10.0) != 1+10j: raise TestFailed, 'complex(1.0,10.0)' +if complex(3.14+0j) != 3.14+0j: raise TestFailed, 'complex(3.14)' +if complex(3.14) != 3.14+0j: raise TestFailed, 'complex(3.14)' +if complex(314) != 314.0+0j: raise TestFailed, 'complex(314)' +if complex(314L) != 314.0+0j: raise TestFailed, 'complex(314L)' +if complex(3.14+0j, 0j) != 3.14+0j: raise TestFailed, 'complex(3.14, 0j)' +if complex(3.14, 0.0) != 3.14+0j: raise TestFailed, 'complex(3.14, 0.0)' +if complex(314, 0) != 314.0+0j: raise TestFailed, 'complex(314, 0)' +if complex(314L, 0L) != 314.0+0j: raise TestFailed, 'complex(314L, 0L)' +if complex(0j, 3.14j) != -3.14+0j: raise TestFailed, 'complex(0j, 3.14j)' +if complex(0.0, 3.14j) != -3.14+0j: raise TestFailed, 'complex(0.0, 3.14j)' +if complex(0j, 3.14) != 3.14j: raise TestFailed, 'complex(0j, 3.14)' +if complex(0.0, 3.14) != 3.14j: raise TestFailed, 'complex(0.0, 3.14)' +if complex(" 3.14+J ") != 3.14+1j: raise TestFailed, 'complex(" 3.14+J )"' +if complex(u" 3.14+J ") != 3.14+1j: raise TestFailed, 'complex(u" 3.14+J )"' class Z: def __complex__(self): return 3.14j z = Z() -if complex(z) <> 3.14j: raise TestFailed, 'complex(classinstance)' +if complex(z) != 3.14j: raise TestFailed, 'complex(classinstance)' print 'delattr' import sys @@ -124,20 +124,20 @@ import sys if 'modules' not in dir(sys): raise TestFailed, 'dir(sys)' print 'divmod' -if divmod(12, 7) <> (1, 5): raise TestFailed, 'divmod(12, 7)' -if divmod(-12, 7) <> (-2, 2): raise TestFailed, 'divmod(-12, 7)' -if divmod(12, -7) <> (-2, -2): raise TestFailed, 'divmod(12, -7)' -if divmod(-12, -7) <> (1, -5): raise TestFailed, 'divmod(-12, -7)' +if divmod(12, 7) != (1, 5): raise TestFailed, 'divmod(12, 7)' +if divmod(-12, 7) != (-2, 2): raise TestFailed, 'divmod(-12, 7)' +if divmod(12, -7) != (-2, -2): raise TestFailed, 'divmod(12, -7)' +if divmod(-12, -7) != (1, -5): raise TestFailed, 'divmod(-12, -7)' # -if divmod(12L, 7L) <> (1L, 5L): raise TestFailed, 'divmod(12L, 7L)' -if divmod(-12L, 7L) <> (-2L, 2L): raise TestFailed, 'divmod(-12L, 7L)' -if divmod(12L, -7L) <> (-2L, -2L): raise TestFailed, 'divmod(12L, -7L)' -if divmod(-12L, -7L) <> (1L, -5L): raise TestFailed, 'divmod(-12L, -7L)' +if divmod(12L, 7L) != (1L, 5L): raise TestFailed, 'divmod(12L, 7L)' +if divmod(-12L, 7L) != (-2L, 2L): raise TestFailed, 'divmod(-12L, 7L)' +if divmod(12L, -7L) != (-2L, -2L): raise TestFailed, 'divmod(12L, -7L)' +if divmod(-12L, -7L) != (1L, -5L): raise TestFailed, 'divmod(-12L, -7L)' # -if divmod(12, 7L) <> (1, 5L): raise TestFailed, 'divmod(12, 7L)' -if divmod(-12, 7L) <> (-2, 2L): raise TestFailed, 'divmod(-12, 7L)' -if divmod(12L, -7) <> (-2L, -2): raise TestFailed, 'divmod(12L, -7)' -if divmod(-12L, -7) <> (1L, -5): raise TestFailed, 'divmod(-12L, -7)' +if divmod(12, 7L) != (1, 5L): raise TestFailed, 'divmod(12, 7L)' +if divmod(-12, 7L) != (-2, 2L): raise TestFailed, 'divmod(-12, 7L)' +if divmod(12L, -7) != (-2L, -2): raise TestFailed, 'divmod(12L, -7)' +if divmod(-12L, -7) != (1L, -5): raise TestFailed, 'divmod(-12L, -7)' # if fcmp(divmod(3.25, 1.0), (3.0, 0.25)): raise TestFailed, 'divmod(3.25, 1.0)' @@ -149,29 +149,29 @@ if fcmp(divmod(-3.25, -1.0), (3.0, -0.25)): raise TestFailed, 'divmod(-3.25, -1.0)' print 'eval' -if eval('1+1') <> 2: raise TestFailed, 'eval(\'1+1\')' -if eval(' 1+1\n') <> 2: raise TestFailed, 'eval(\' 1+1\\n\')' +if eval('1+1') != 2: raise TestFailed, 'eval(\'1+1\')' +if eval(' 1+1\n') != 2: raise TestFailed, 'eval(\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} -if eval('a', globals) <> 1: +if eval('a', globals) != 1: raise TestFailed, "eval(1) == %s" % eval('a', globals) -if eval('a', globals, locals) <> 1: +if eval('a', globals, locals) != 1: raise TestFailed, "eval(2)" -if eval('b', globals, locals) <> 200: +if eval('b', globals, locals) != 200: raise TestFailed, "eval(3)" -if eval('c', globals, locals) <> 300: +if eval('c', globals, locals) != 300: raise TestFailed, "eval(4)" -if eval(u'1+1') <> 2: raise TestFailed, 'eval(u\'1+1\')' -if eval(u' 1+1\n') <> 2: raise TestFailed, 'eval(u\' 1+1\\n\')' +if eval(u'1+1') != 2: raise TestFailed, 'eval(u\'1+1\')' +if eval(u' 1+1\n') != 2: raise TestFailed, 'eval(u\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} -if eval(u'a', globals) <> 1: +if eval(u'a', globals) != 1: raise TestFailed, "eval(1) == %s" % eval(u'a', globals) -if eval(u'a', globals, locals) <> 1: +if eval(u'a', globals, locals) != 1: raise TestFailed, "eval(2)" -if eval(u'b', globals, locals) <> 200: +if eval(u'b', globals, locals) != 200: raise TestFailed, "eval(3)" -if eval(u'c', globals, locals) <> 300: +if eval(u'c', globals, locals) != 300: raise TestFailed, "eval(4)" print 'execfile' @@ -181,21 +181,21 @@ f.write('z = z+1\n') f.write('z = z*2\n') f.close() execfile(TESTFN) -if z <> 2: raise TestFailed, "execfile(1)" +if z != 2: raise TestFailed, "execfile(1)" globals['z'] = 0 execfile(TESTFN, globals) -if globals['z'] <> 2: raise TestFailed, "execfile(1)" +if globals['z'] != 2: raise TestFailed, "execfile(1)" locals['z'] = 0 execfile(TESTFN, globals, locals) -if locals['z'] <> 2: raise TestFailed, "execfile(1)" +if locals['z'] != 2: raise TestFailed, "execfile(1)" unlink(TESTFN) print 'filter' -if filter(lambda c: 'a' <= c <= 'z', 'Hello World') <> 'elloorld': +if filter(lambda c: 'a' <= c <= 'z', 'Hello World') != 'elloorld': raise TestFailed, 'filter (filter a string)' -if filter(None, [1, 'hello', [], [3], '', None, 9, 0]) <> [1, 'hello', [3], 9]: +if filter(None, [1, 'hello', [], [3], '', None, 9, 0]) != [1, 'hello', [3], 9]: raise TestFailed, 'filter (remove false values)' -if filter(lambda x: x > 0, [1, -3, 9, 0, 2]) <> [1, 9, 2]: +if filter(lambda x: x > 0, [1, -3, 9, 0, 2]) != [1, 9, 2]: raise TestFailed, 'filter (keep positives)' class Squares: def __init__(self, max): @@ -232,12 +232,12 @@ def identity(item): filter(identity, Squares(5)) print 'float' -if float(3.14) <> 3.14: raise TestFailed, 'float(3.14)' -if float(314) <> 314.0: raise TestFailed, 'float(314)' -if float(314L) <> 314.0: raise TestFailed, 'float(314L)' -if float(" 3.14 ") <> 3.14: raise TestFailed, 'float(" 3.14 ")' -if float(u" 3.14 ") <> 3.14: raise TestFailed, 'float(u" 3.14 ")' -if float(u" \u0663.\u0661\u0664 ") <> 3.14: +if float(3.14) != 3.14: raise TestFailed, 'float(3.14)' +if float(314) != 314.0: raise TestFailed, 'float(314)' +if float(314L) != 314.0: raise TestFailed, 'float(314L)' +if float(" 3.14 ") != 3.14: raise TestFailed, 'float(" 3.14 ")' +if float(u" 3.14 ") != 3.14: raise TestFailed, 'float(u" 3.14 ")' +if float(u" \u0663.\u0661\u0664 ") != 3.14: raise TestFailed, 'float(u" \u0663.\u0661\u0664 ")' print 'getattr' @@ -276,18 +276,18 @@ id({'spam': 1, 'eggs': 2, 'ham': 3}) # Test input() later, together with raw_input print 'int' -if int(314) <> 314: raise TestFailed, 'int(314)' -if int(3.14) <> 3: raise TestFailed, 'int(3.14)' -if int(314L) <> 314: raise TestFailed, 'int(314L)' +if int(314) != 314: raise TestFailed, 'int(314)' +if int(3.14) != 3: raise TestFailed, 'int(3.14)' +if int(314L) != 314: raise TestFailed, 'int(314L)' # Check that conversion from float truncates towards zero -if int(-3.14) <> -3: raise TestFailed, 'int(-3.14)' -if int(3.9) <> 3: raise TestFailed, 'int(3.9)' -if int(-3.9) <> -3: raise TestFailed, 'int(-3.9)' -if int(3.5) <> 3: raise TestFailed, 'int(3.5)' -if int(-3.5) <> -3: raise TestFailed, 'int(-3.5)' +if int(-3.14) != -3: raise TestFailed, 'int(-3.14)' +if int(3.9) != 3: raise TestFailed, 'int(3.9)' +if int(-3.9) != -3: raise TestFailed, 'int(-3.9)' +if int(3.5) != 3: raise TestFailed, 'int(3.5)' +if int(-3.5) != -3: raise TestFailed, 'int(-3.5)' # Different base: -if int("10",16) <> 16L: raise TestFailed, 'int("10",16)' -if int(u"10",16) <> 16L: raise TestFailed, 'int(u"10",16)' +if int("10",16) != 16L: raise TestFailed, 'int("10",16)' +if int(u"10",16) != 16L: raise TestFailed, 'int(u"10",16)' # Test conversion from strings and various anomalies L = [ ('0', 0), @@ -385,28 +385,28 @@ except TypeError: pass print 'len' -if len('123') <> 3: raise TestFailed, 'len(\'123\')' -if len(()) <> 0: raise TestFailed, 'len(())' -if len((1, 2, 3, 4)) <> 4: raise TestFailed, 'len((1, 2, 3, 4))' -if len([1, 2, 3, 4]) <> 4: raise TestFailed, 'len([1, 2, 3, 4])' -if len({}) <> 0: raise TestFailed, 'len({})' -if len({'a':1, 'b': 2}) <> 2: raise TestFailed, 'len({\'a\':1, \'b\': 2})' +if len('123') != 3: raise TestFailed, 'len(\'123\')' +if len(()) != 0: raise TestFailed, 'len(())' +if len((1, 2, 3, 4)) != 4: raise TestFailed, 'len((1, 2, 3, 4))' +if len([1, 2, 3, 4]) != 4: raise TestFailed, 'len([1, 2, 3, 4])' +if len({}) != 0: raise TestFailed, 'len({})' +if len({'a':1, 'b': 2}) != 2: raise TestFailed, 'len({\'a\':1, \'b\': 2})' print 'long' -if long(314) <> 314L: raise TestFailed, 'long(314)' -if long(3.14) <> 3L: raise TestFailed, 'long(3.14)' -if long(314L) <> 314L: raise TestFailed, 'long(314L)' +if long(314) != 314L: raise TestFailed, 'long(314)' +if long(3.14) != 3L: raise TestFailed, 'long(3.14)' +if long(314L) != 314L: raise TestFailed, 'long(314L)' # Check that conversion from float truncates towards zero -if long(-3.14) <> -3L: raise TestFailed, 'long(-3.14)' -if long(3.9) <> 3L: raise TestFailed, 'long(3.9)' -if long(-3.9) <> -3L: raise TestFailed, 'long(-3.9)' -if long(3.5) <> 3L: raise TestFailed, 'long(3.5)' -if long(-3.5) <> -3L: raise TestFailed, 'long(-3.5)' -if long("-3") <> -3L: raise TestFailed, 'long("-3")' -if long(u"-3") <> -3L: raise TestFailed, 'long(u"-3")' +if long(-3.14) != -3L: raise TestFailed, 'long(-3.14)' +if long(3.9) != 3L: raise TestFailed, 'long(3.9)' +if long(-3.9) != -3L: raise TestFailed, 'long(-3.9)' +if long(3.5) != 3L: raise TestFailed, 'long(3.5)' +if long(-3.5) != -3L: raise TestFailed, 'long(-3.5)' +if long("-3") != -3L: raise TestFailed, 'long("-3")' +if long(u"-3") != -3L: raise TestFailed, 'long(u"-3")' # Different base: -if long("10",16) <> 16L: raise TestFailed, 'long("10",16)' -if long(u"10",16) <> 16L: raise TestFailed, 'long(u"10",16)' +if long("10",16) != 16L: raise TestFailed, 'long("10",16)' +if long(u"10",16) != 16L: raise TestFailed, 'long(u"10",16)' # Check conversions from string (same test set as for int(), and then some) LL = [ ('1' + '0'*20, 10L**20), @@ -430,33 +430,33 @@ for s, v in L + LL: raise TestFailed, "long(%s) raised ValueError: %s" % (`ss`, e) print 'map' -if map(None, 'hello world') <> ['h','e','l','l','o',' ','w','o','r','l','d']: +if map(None, 'hello world') != ['h','e','l','l','o',' ','w','o','r','l','d']: raise TestFailed, 'map(None, \'hello world\')' -if map(None, 'abcd', 'efg') <> \ +if map(None, 'abcd', 'efg') != \ [('a', 'e'), ('b', 'f'), ('c', 'g'), ('d', None)]: raise TestFailed, 'map(None, \'abcd\', \'efg\')' -if map(None, range(10)) <> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]: +if map(None, range(10)) != [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]: raise TestFailed, 'map(None, range(10))' -if map(lambda x: x*x, range(1,4)) <> [1, 4, 9]: +if map(lambda x: x*x, range(1,4)) != [1, 4, 9]: raise TestFailed, 'map(lambda x: x*x, range(1,4))' try: from math import sqrt except ImportError: def sqrt(x): return pow(x, 0.5) -if map(lambda x: map(sqrt,x), [[16, 4], [81, 9]]) <> [[4.0, 2.0], [9.0, 3.0]]: +if map(lambda x: map(sqrt,x), [[16, 4], [81, 9]]) != [[4.0, 2.0], [9.0, 3.0]]: raise TestFailed, 'map(lambda x: map(sqrt,x), [[16, 4], [81, 9]])' -if map(lambda x, y: x+y, [1,3,2], [9,1,4]) <> [10, 4, 6]: +if map(lambda x, y: x+y, [1,3,2], [9,1,4]) != [10, 4, 6]: raise TestFailed, 'map(lambda x,y: x+y, [1,3,2], [9,1,4])' def plus(*v): accu = 0 for i in v: accu = accu + i return accu -if map(plus, [1, 3, 7]) <> [1, 3, 7]: +if map(plus, [1, 3, 7]) != [1, 3, 7]: raise TestFailed, 'map(plus, [1, 3, 7])' -if map(plus, [1, 3, 7], [4, 9, 2]) <> [1+4, 3+9, 7+2]: +if map(plus, [1, 3, 7], [4, 9, 2]) != [1+4, 3+9, 7+2]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2])' -if map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0]) <> [1+4+1, 3+9+1, 7+2+0]: +if map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0]) != [1+4+1, 3+9+1, 7+2+0]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0])' if map(None, Squares(10)) != [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]: raise TestFailed, 'map(None, Squares(10))' @@ -468,21 +468,21 @@ if map(max, Squares(3), Squares(2)) != [0, 1, None]: raise TestFailed, 'map(max, Squares(3), Squares(2))' print 'max' -if max('123123') <> '3': raise TestFailed, 'max(\'123123\')' -if max(1, 2, 3) <> 3: raise TestFailed, 'max(1, 2, 3)' -if max((1, 2, 3, 1, 2, 3)) <> 3: raise TestFailed, 'max((1, 2, 3, 1, 2, 3))' -if max([1, 2, 3, 1, 2, 3]) <> 3: raise TestFailed, 'max([1, 2, 3, 1, 2, 3])' +if max('123123') != '3': raise TestFailed, 'max(\'123123\')' +if max(1, 2, 3) != 3: raise TestFailed, 'max(1, 2, 3)' +if max((1, 2, 3, 1, 2, 3)) != 3: raise TestFailed, 'max((1, 2, 3, 1, 2, 3))' +if max([1, 2, 3, 1, 2, 3]) != 3: raise TestFailed, 'max([1, 2, 3, 1, 2, 3])' # -if max(1, 2L, 3.0) <> 3.0: raise TestFailed, 'max(1, 2L, 3.0)' -if max(1L, 2.0, 3) <> 3: raise TestFailed, 'max(1L, 2.0, 3)' -if max(1.0, 2, 3L) <> 3L: raise TestFailed, 'max(1.0, 2, 3L)' +if max(1, 2L, 3.0) != 3.0: raise TestFailed, 'max(1, 2L, 3.0)' +if max(1L, 2.0, 3) != 3: raise TestFailed, 'max(1L, 2.0, 3)' +if max(1.0, 2, 3L) != 3L: raise TestFailed, 'max(1.0, 2, 3L)' print 'min' -if min('123123') <> '1': raise TestFailed, 'min(\'123123\')' -if min(1, 2, 3) <> 1: raise TestFailed, 'min(1, 2, 3)' -if min((1, 2, 3, 1, 2, 3)) <> 1: raise TestFailed, 'min((1, 2, 3, 1, 2, 3))' -if min([1, 2, 3, 1, 2, 3]) <> 1: raise TestFailed, 'min([1, 2, 3, 1, 2, 3])' +if min('123123') != '1': raise TestFailed, 'min(\'123123\')' +if min(1, 2, 3) != 1: raise TestFailed, 'min(1, 2, 3)' +if min((1, 2, 3, 1, 2, 3)) != 1: raise TestFailed, 'min((1, 2, 3, 1, 2, 3))' +if min([1, 2, 3, 1, 2, 3]) != 1: raise TestFailed, 'min([1, 2, 3, 1, 2, 3])' # -if min(1, 2L, 3.0) <> 1: raise TestFailed, 'min(1, 2L, 3.0)' -if min(1L, 2.0, 3) <> 1L: raise TestFailed, 'min(1L, 2.0, 3)' -if min(1.0, 2, 3L) <> 1.0: raise TestFailed, 'min(1.0, 2, 3L)' +if min(1, 2L, 3.0) != 1: raise TestFailed, 'min(1, 2L, 3.0)' +if min(1L, 2.0, 3) != 1L: raise TestFailed, 'min(1L, 2.0, 3)' +if min(1.0, 2, 3L) != 1.0: raise TestFailed, 'min(1.0, 2, 3L)' diff --git a/Lib/test/test_b2.py b/Lib/test/test_b2.py index c212f2e..5546d8a 100644 --- a/Lib/test/test_b2.py +++ b/Lib/test/test_b2.py @@ -25,52 +25,52 @@ finally: # fp = open(TESTFN, 'r') try: - if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact' - if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact' - if fp.readline() <> 'The quick brown fox jumps over the lazy dog.\n': + if fp.readline(4) != '1+1\n': raise TestFailed, 'readline(4) # exact' + if fp.readline(4) != '1+1\n': raise TestFailed, 'readline(4) # exact' + if fp.readline() != 'The quick brown fox jumps over the lazy dog.\n': raise TestFailed, 'readline() # default' - if fp.readline(4) <> 'Dear': raise TestFailed, 'readline(4) # short' - if fp.readline(100) <> ' John\n': raise TestFailed, 'readline(100)' - if fp.read(300) <> 'XXX'*100: raise TestFailed, 'read(300)' - if fp.read(1000) <> 'YYY'*100: raise TestFailed, 'read(1000) # truncate' + if fp.readline(4) != 'Dear': raise TestFailed, 'readline(4) # short' + if fp.readline(100) != ' John\n': raise TestFailed, 'readline(100)' + if fp.read(300) != 'XXX'*100: raise TestFailed, 'read(300)' + if fp.read(1000) != 'YYY'*100: raise TestFailed, 'read(1000) # truncate' finally: fp.close() print 'ord' -if ord(' ') <> 32: raise TestFailed, 'ord(\' \')' -if ord('A') <> 65: raise TestFailed, 'ord(\'A\')' -if ord('a') <> 97: raise TestFailed, 'ord(\'a\')' +if ord(' ') != 32: raise TestFailed, 'ord(\' \')' +if ord('A') != 65: raise TestFailed, 'ord(\'A\')' +if ord('a') != 97: raise TestFailed, 'ord(\'a\')' print 'pow' -if pow(0,0) <> 1: raise TestFailed, 'pow(0,0)' -if pow(0,1) <> 0: raise TestFailed, 'pow(0,1)' -if pow(1,0) <> 1: raise TestFailed, 'pow(1,0)' -if pow(1,1) <> 1: raise TestFailed, 'pow(1,1)' +if pow(0,0) != 1: raise TestFailed, 'pow(0,0)' +if pow(0,1) != 0: raise TestFailed, 'pow(0,1)' +if pow(1,0) != 1: raise TestFailed, 'pow(1,0)' +if pow(1,1) != 1: raise TestFailed, 'pow(1,1)' # -if pow(2,0) <> 1: raise TestFailed, 'pow(2,0)' -if pow(2,10) <> 1024: raise TestFailed, 'pow(2,10)' -if pow(2,20) <> 1024*1024: raise TestFailed, 'pow(2,20)' -if pow(2,30) <> 1024*1024*1024: raise TestFailed, 'pow(2,30)' +if pow(2,0) != 1: raise TestFailed, 'pow(2,0)' +if pow(2,10) != 1024: raise TestFailed, 'pow(2,10)' +if pow(2,20) != 1024*1024: raise TestFailed, 'pow(2,20)' +if pow(2,30) != 1024*1024*1024: raise TestFailed, 'pow(2,30)' # -if pow(-2,0) <> 1: raise TestFailed, 'pow(-2,0)' -if pow(-2,1) <> -2: raise TestFailed, 'pow(-2,1)' -if pow(-2,2) <> 4: raise TestFailed, 'pow(-2,2)' -if pow(-2,3) <> -8: raise TestFailed, 'pow(-2,3)' +if pow(-2,0) != 1: raise TestFailed, 'pow(-2,0)' +if pow(-2,1) != -2: raise TestFailed, 'pow(-2,1)' +if pow(-2,2) != 4: raise TestFailed, 'pow(-2,2)' +if pow(-2,3) != -8: raise TestFailed, 'pow(-2,3)' # -if pow(0L,0) <> 1: raise TestFailed, 'pow(0L,0)' -if pow(0L,1) <> 0: raise TestFailed, 'pow(0L,1)' -if pow(1L,0) <> 1: raise TestFailed, 'pow(1L,0)' -if pow(1L,1) <> 1: raise TestFailed, 'pow(1L,1)' +if pow(0L,0) != 1: raise TestFailed, 'pow(0L,0)' +if pow(0L,1) != 0: raise TestFailed, 'pow(0L,1)' +if pow(1L,0) != 1: raise TestFailed, 'pow(1L,0)' +if pow(1L,1) != 1: raise TestFailed, 'pow(1L,1)' # -if pow(2L,0) <> 1: raise TestFailed, 'pow(2L,0)' -if pow(2L,10) <> 1024: raise TestFailed, 'pow(2L,10)' -if pow(2L,20) <> 1024*1024: raise TestFailed, 'pow(2L,20)' -if pow(2L,30) <> 1024*1024*1024: raise TestFailed, 'pow(2L,30)' +if pow(2L,0) != 1: raise TestFailed, 'pow(2L,0)' +if pow(2L,10) != 1024: raise TestFailed, 'pow(2L,10)' +if pow(2L,20) != 1024*1024: raise TestFailed, 'pow(2L,20)' +if pow(2L,30) != 1024*1024*1024: raise TestFailed, 'pow(2L,30)' # -if pow(-2L,0) <> 1: raise TestFailed, 'pow(-2L,0)' -if pow(-2L,1) <> -2: raise TestFailed, 'pow(-2L,1)' -if pow(-2L,2) <> 4: raise TestFailed, 'pow(-2L,2)' -if pow(-2L,3) <> -8: raise TestFailed, 'pow(-2L,3)' +if pow(-2L,0) != 1: raise TestFailed, 'pow(-2L,0)' +if pow(-2L,1) != -2: raise TestFailed, 'pow(-2L,1)' +if pow(-2L,2) != 4: raise TestFailed, 'pow(-2L,2)' +if pow(-2L,3) != -8: raise TestFailed, 'pow(-2L,3)' # if fcmp(pow(0.,0), 1.): raise TestFailed, 'pow(0.,0)' if fcmp(pow(0.,1), 0.): raise TestFailed, 'pow(0.,1)' @@ -95,12 +95,12 @@ for x in 2, 2L, 2.0: raise TestFailed, 'pow(%s, %s, %s)' % (x, y, z) print 'range' -if range(3) <> [0, 1, 2]: raise TestFailed, 'range(3)' -if range(1, 5) <> [1, 2, 3, 4]: raise TestFailed, 'range(1, 5)' -if range(0) <> []: raise TestFailed, 'range(0)' -if range(-3) <> []: raise TestFailed, 'range(-3)' -if range(1, 10, 3) <> [1, 4, 7]: raise TestFailed, 'range(1, 10, 3)' -if range(5, -5, -3) <> [5, 2, -1, -4]: raise TestFailed, 'range(5, -5, -3)' +if range(3) != [0, 1, 2]: raise TestFailed, 'range(3)' +if range(1, 5) != [1, 2, 3, 4]: raise TestFailed, 'range(1, 5)' +if range(0) != []: raise TestFailed, 'range(0)' +if range(-3) != []: raise TestFailed, 'range(-3)' +if range(1, 10, 3) != [1, 4, 7]: raise TestFailed, 'range(1, 10, 3)' +if range(5, -5, -3) != [5, 2, -1, -4]: raise TestFailed, 'range(5, -5, -3)' print 'input and raw_input' import sys @@ -108,25 +108,25 @@ fp = open(TESTFN, 'r') savestdin = sys.stdin try: sys.stdin = fp - if input() <> 2: raise TestFailed, 'input()' - if input('testing\n') <> 2: raise TestFailed, 'input()' - if raw_input() <> 'The quick brown fox jumps over the lazy dog.': + if input() != 2: raise TestFailed, 'input()' + if input('testing\n') != 2: raise TestFailed, 'input()' + if raw_input() != 'The quick brown fox jumps over the lazy dog.': raise TestFailed, 'raw_input()' - if raw_input('testing\n') <> 'Dear John': + if raw_input('testing\n') != 'Dear John': raise TestFailed, 'raw_input(\'testing\\n\')' finally: sys.stdin = savestdin fp.close() print 'reduce' -if reduce(lambda x, y: x+y, ['a', 'b', 'c'], '') <> 'abc': +if reduce(lambda x, y: x+y, ['a', 'b', 'c'], '') != 'abc': raise TestFailed, 'reduce(): implode a string' if reduce(lambda x, y: x+y, - [['a', 'c'], [], ['d', 'w']], []) <> ['a','c','d','w']: + [['a', 'c'], [], ['d', 'w']], []) != ['a','c','d','w']: raise TestFailed, 'reduce(): append' -if reduce(lambda x, y: x*y, range(2,8), 1) <> 5040: +if reduce(lambda x, y: x*y, range(2,8), 1) != 5040: raise TestFailed, 'reduce(): compute 7!' -if reduce(lambda x, y: x*y, range(2,21), 1L) <> 2432902008176640000L: +if reduce(lambda x, y: x*y, range(2,21), 1L) != 2432902008176640000L: raise TestFailed, 'reduce(): compute 20!, use long' class Squares: def __init__(self, max): @@ -159,46 +159,46 @@ reload(string) ## else: raise TestFailed, 'reload(sys) should fail' print 'repr' -if repr('') <> '\'\'': raise TestFailed, 'repr(\'\')' -if repr(0) <> '0': raise TestFailed, 'repr(0)' -if repr(0L) <> '0L': raise TestFailed, 'repr(0L)' -if repr(()) <> '()': raise TestFailed, 'repr(())' -if repr([]) <> '[]': raise TestFailed, 'repr([])' -if repr({}) <> '{}': raise TestFailed, 'repr({})' +if repr('') != '\'\'': raise TestFailed, 'repr(\'\')' +if repr(0) != '0': raise TestFailed, 'repr(0)' +if repr(0L) != '0L': raise TestFailed, 'repr(0L)' +if repr(()) != '()': raise TestFailed, 'repr(())' +if repr([]) != '[]': raise TestFailed, 'repr([])' +if repr({}) != '{}': raise TestFailed, 'repr({})' print 'round' -if round(0.0) <> 0.0: raise TestFailed, 'round(0.0)' -if round(1.0) <> 1.0: raise TestFailed, 'round(1.0)' -if round(10.0) <> 10.0: raise TestFailed, 'round(10.0)' -if round(1000000000.0) <> 1000000000.0: +if round(0.0) != 0.0: raise TestFailed, 'round(0.0)' +if round(1.0) != 1.0: raise TestFailed, 'round(1.0)' +if round(10.0) != 10.0: raise TestFailed, 'round(10.0)' +if round(1000000000.0) != 1000000000.0: raise TestFailed, 'round(1000000000.0)' -if round(1e20) <> 1e20: raise TestFailed, 'round(1e20)' +if round(1e20) != 1e20: raise TestFailed, 'round(1e20)' -if round(-1.0) <> -1.0: raise TestFailed, 'round(-1.0)' -if round(-10.0) <> -10.0: raise TestFailed, 'round(-10.0)' -if round(-1000000000.0) <> -1000000000.0: +if round(-1.0) != -1.0: raise TestFailed, 'round(-1.0)' +if round(-10.0) != -10.0: raise TestFailed, 'round(-10.0)' +if round(-1000000000.0) != -1000000000.0: raise TestFailed, 'round(-1000000000.0)' -if round(-1e20) <> -1e20: raise TestFailed, 'round(-1e20)' +if round(-1e20) != -1e20: raise TestFailed, 'round(-1e20)' -if round(0.1) <> 0.0: raise TestFailed, 'round(0.0)' -if round(1.1) <> 1.0: raise TestFailed, 'round(1.0)' -if round(10.1) <> 10.0: raise TestFailed, 'round(10.0)' -if round(1000000000.1) <> 1000000000.0: +if round(0.1) != 0.0: raise TestFailed, 'round(0.0)' +if round(1.1) != 1.0: raise TestFailed, 'round(1.0)' +if round(10.1) != 10.0: raise TestFailed, 'round(10.0)' +if round(1000000000.1) != 1000000000.0: raise TestFailed, 'round(1000000000.0)' -if round(-1.1) <> -1.0: raise TestFailed, 'round(-1.0)' -if round(-10.1) <> -10.0: raise TestFailed, 'round(-10.0)' -if round(-1000000000.1) <> -1000000000.0: +if round(-1.1) != -1.0: raise TestFailed, 'round(-1.0)' +if round(-10.1) != -10.0: raise TestFailed, 'round(-10.0)' +if round(-1000000000.1) != -1000000000.0: raise TestFailed, 'round(-1000000000.0)' -if round(0.9) <> 1.0: raise TestFailed, 'round(0.9)' -if round(9.9) <> 10.0: raise TestFailed, 'round(9.9)' -if round(999999999.9) <> 1000000000.0: +if round(0.9) != 1.0: raise TestFailed, 'round(0.9)' +if round(9.9) != 10.0: raise TestFailed, 'round(9.9)' +if round(999999999.9) != 1000000000.0: raise TestFailed, 'round(999999999.9)' -if round(-0.9) <> -1.0: raise TestFailed, 'round(-0.9)' -if round(-9.9) <> -10.0: raise TestFailed, 'round(-9.9)' -if round(-999999999.9) <> -1000000000.0: +if round(-0.9) != -1.0: raise TestFailed, 'round(-0.9)' +if round(-9.9) != -10.0: raise TestFailed, 'round(-9.9)' +if round(-999999999.9) != -1000000000.0: raise TestFailed, 'round(-999999999.9)' print 'setattr' @@ -207,23 +207,23 @@ setattr(sys, 'spam', 1) if sys.spam != 1: raise TestFailed, 'setattr(sys, \'spam\', 1)' print 'str' -if str('') <> '': raise TestFailed, 'str(\'\')' -if str(0) <> '0': raise TestFailed, 'str(0)' -if str(0L) <> '0': raise TestFailed, 'str(0L)' -if str(()) <> '()': raise TestFailed, 'str(())' -if str([]) <> '[]': raise TestFailed, 'str([])' -if str({}) <> '{}': raise TestFailed, 'str({})' +if str('') != '': raise TestFailed, 'str(\'\')' +if str(0) != '0': raise TestFailed, 'str(0)' +if str(0L) != '0': raise TestFailed, 'str(0L)' +if str(()) != '()': raise TestFailed, 'str(())' +if str([]) != '[]': raise TestFailed, 'str([])' +if str({}) != '{}': raise TestFailed, 'str({})' print 'tuple' -if tuple(()) <> (): raise TestFailed, 'tuple(())' -if tuple((0, 1, 2, 3)) <> (0, 1, 2, 3): raise TestFailed, 'tuple((0, 1, 2, 3))' -if tuple([]) <> (): raise TestFailed, 'tuple([])' -if tuple([0, 1, 2, 3]) <> (0, 1, 2, 3): raise TestFailed, 'tuple([0, 1, 2, 3])' -if tuple('') <> (): raise TestFailed, 'tuple('')' -if tuple('spam') <> ('s', 'p', 'a', 'm'): raise TestFailed, "tuple('spam')" +if tuple(()) != (): raise TestFailed, 'tuple(())' +if tuple((0, 1, 2, 3)) != (0, 1, 2, 3): raise TestFailed, 'tuple((0, 1, 2, 3))' +if tuple([]) != (): raise TestFailed, 'tuple([])' +if tuple([0, 1, 2, 3]) != (0, 1, 2, 3): raise TestFailed, 'tuple([0, 1, 2, 3])' +if tuple('') != (): raise TestFailed, 'tuple('')' +if tuple('spam') != ('s', 'p', 'a', 'm'): raise TestFailed, "tuple('spam')" print 'type' -if type('') <> type('123') or type('') == type(()): +if type('') != type('123') or type('') == type(()): raise TestFailed, 'type()' print 'vars' @@ -232,13 +232,13 @@ a = vars().keys() b = dir() a.sort() b.sort() -if a <> b: raise TestFailed, 'vars()' +if a != b: raise TestFailed, 'vars()' import sys a = vars(sys).keys() b = dir(sys) a.sort() b.sort() -if a <> b: raise TestFailed, 'vars(sys)' +if a != b: raise TestFailed, 'vars(sys)' def f0(): if vars() != {}: raise TestFailed, 'vars() in f0()' f0() @@ -250,9 +250,9 @@ def f2(): f2() print 'xrange' -if tuple(xrange(10)) <> tuple(range(10)): raise TestFailed, 'xrange(10)' -if tuple(xrange(5,10)) <> tuple(range(5,10)): raise TestFailed, 'xrange(5,10)' -if tuple(xrange(0,10,2)) <> tuple(range(0,10,2)): +if tuple(xrange(10)) != tuple(range(10)): raise TestFailed, 'xrange(10)' +if tuple(xrange(5,10)) != tuple(range(5,10)): raise TestFailed, 'xrange(5,10)' +if tuple(xrange(0,10,2)) != tuple(range(0,10,2)): raise TestFailed, 'xrange(0,10,2)' # regression tests for SourceForge bug #121695 def _range_test(r): @@ -273,16 +273,16 @@ print 'zip' a = (1, 2, 3) b = (4, 5, 6) t = [(1, 4), (2, 5), (3, 6)] -if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - same size, both tuples' +if zip(a, b) != t: raise TestFailed, 'zip(a, b) - same size, both tuples' b = [4, 5, 6] -if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - same size, tuple/list' +if zip(a, b) != t: raise TestFailed, 'zip(a, b) - same size, tuple/list' b = (4, 5, 6, 7) -if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - b is longer' +if zip(a, b) != t: raise TestFailed, 'zip(a, b) - b is longer' class I: def __getitem__(self, i): if i < 0 or i > 2: raise IndexError return i + 4 -if zip(a, I()) <> t: raise TestFailed, 'zip(a, b) - b is instance' +if zip(a, I()) != t: raise TestFailed, 'zip(a, b) - b is instance' exc = 0 try: zip() diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index 52f817b..20f5400 100755 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -96,7 +96,7 @@ if crc != 1571220330: s = '{s\005\000\000\000worldi\002\000\000\000s\005\000\000\000helloi\001\000\000\0000' t = binascii.b2a_hex(s) u = binascii.a2b_hex(t) -if s <> u: +if s != u: print 'binascii hexlification failed' try: binascii.a2b_hex(t[:-1]) diff --git a/Lib/test/test_binhex.py b/Lib/test/test_binhex.py index 68012f8..4dfe14e 100755 --- a/Lib/test/test_binhex.py +++ b/Lib/test/test_binhex.py @@ -32,8 +32,8 @@ def test(): f = open(fname1, 'r') finish = f.readline() - if start <> finish: - print 'Error: binhex <> hexbin' + if start != finish: + print 'Error: binhex != hexbin' elif verbose: print 'binhex == hexbin' diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py index aa65295..b59a4e0 100755 --- a/Lib/test/test_bsddb.py +++ b/Lib/test/test_bsddb.py @@ -34,8 +34,8 @@ def test(openmethod, what): try: rec = f.next() except KeyError: - if rec <> f.last(): - print 'Error, last <> last!' + if rec != f.last(): + print 'Error, last != last!' f.previous() break if verbose: diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 7dcad07..b990c83 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -12,17 +12,17 @@ print '1.1.1 Backslashes' # Backslash means line continuation: x = 1 \ + 1 -if x <> 2: raise TestFailed, 'backslash for line continuation' +if x != 2: raise TestFailed, 'backslash for line continuation' # Backslash does not means continuation in comments :\ x = 0 -if x <> 0: raise TestFailed, 'backslash ending comment' +if x != 0: raise TestFailed, 'backslash ending comment' print '1.1.2 Numeric literals' print '1.1.2.1 Plain integers' -if 0xff <> 255: raise TestFailed, 'hex int' -if 0377 <> 255: raise TestFailed, 'octal int' +if 0xff != 255: raise TestFailed, 'hex int' +if 0377 != 255: raise TestFailed, 'octal int' if 2147483647 != 017777777777: raise TestFailed, 'large positive int' try: from sys import maxint @@ -359,28 +359,28 @@ def f(): z = None del z exec 'z=1+1\n' - if z <> 2: raise TestFailed, 'exec \'z=1+1\'\\n' + if z != 2: raise TestFailed, 'exec \'z=1+1\'\\n' del z exec 'z=1+1' - if z <> 2: raise TestFailed, 'exec \'z=1+1\'' + if z != 2: raise TestFailed, 'exec \'z=1+1\'' z = None del z exec u'z=1+1\n' - if z <> 2: raise TestFailed, 'exec u\'z=1+1\'\\n' + if z != 2: raise TestFailed, 'exec u\'z=1+1\'\\n' del z exec u'z=1+1' - if z <> 2: raise TestFailed, 'exec u\'z=1+1\'' + if z != 2: raise TestFailed, 'exec u\'z=1+1\'' f() g = {} exec 'z = 1' in g if g.has_key('__builtins__'): del g['__builtins__'] -if g <> {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g' +if g != {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g' g = {} l = {} exec 'global a; a = 1; b = 2' in g, l if g.has_key('__builtins__'): del g['__builtins__'] if l.has_key('__builtins__'): del l['__builtins__'] -if (g, l) <> ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g, l' +if (g, l) != ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g, l' ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 888d277..8419a1f 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -85,7 +85,7 @@ 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: + if abs(mant-emant) > eps or exp != eexp: raise TestFailed, '%s returned %s, expected %s'%\ (name, `mant, exp`, `emant,eexp`) diff --git a/Lib/test/test_md5.py b/Lib/test/test_md5.py index e2d3f22..92cd568 100644 --- a/Lib/test/test_md5.py +++ b/Lib/test/test_md5.py @@ -26,5 +26,5 @@ print md5test('12345678901234567890123456789012345678901234567890123456789012345 # hexdigest is new with Python 2.0 m = md5('testing the hexdigest method') h = m.hexdigest() -if hexstr(m.digest()) <> h: +if hexstr(m.digest()) != h: print 'hexdigest() failed' diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 3e2d89f..d07e4c6 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -46,7 +46,7 @@ def test_both(): # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) - if match == None: + if match is None: print ' ERROR: regex match on mmap failed!' else: start, end = match.span(0) diff --git a/Lib/test/test_new.py b/Lib/test/test_new.py index a693d8b..70ea38b 100644 --- a/Lib/test/test_new.py +++ b/Lib/test/test_new.py @@ -33,10 +33,10 @@ im = new.instancemethod(break_yolks, c, C) if verbose: print im -if c.get_yolks() <> 3 and c.get_more_yolks() <> 6: +if c.get_yolks() != 3 and c.get_more_yolks() != 6: print 'Broken call of hand-crafted class instance' im() -if c.get_yolks() <> 1 and c.get_more_yolks() <> 4: +if c.get_yolks() != 1 and c.get_more_yolks() != 4: print 'Broken call of hand-crafted instance method' codestr = ''' @@ -53,7 +53,7 @@ func = new.function(ccode, g) if verbose: print func func() -if g['c'] <> 3: +if g['c'] != 3: print 'Could not create a proper function object' # bogus test of new.code() diff --git a/Lib/test/test_nis.py b/Lib/test/test_nis.py index f711de0..e1670d1 100644 --- a/Lib/test/test_nis.py +++ b/Lib/test/test_nis.py @@ -21,7 +21,7 @@ for nismap in maps: print ' ', k, v if not k: continue - if nis.match(k, nismap) <> v: + if nis.match(k, nismap) != v: print "NIS match failed for key `%s' in map `%s'" % (k, nismap) else: # just test the one key, otherwise this test could take a diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py index 94a0a92..5381e4d 100644 --- a/Lib/test/test_opcodes.py +++ b/Lib/test/test_opcodes.py @@ -19,7 +19,7 @@ for i in range(10): try: pass finally: pass n = n+i -if n <> 90: +if n != 90: raise TestFailed, 'try inside for' diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py index 8d3864c..b75c5ba 100644 --- a/Lib/test/test_operator.py +++ b/Lib/test/test_operator.py @@ -9,7 +9,7 @@ def test(name, input, output, *args): val = apply(f, params) except: val = sys.exc_type - if val <> output: + if val != output: print '%s%s = %s: %s expected' % (f.__name__, params, `val`, `output`) test('abs', -1, 1) @@ -21,12 +21,12 @@ test('countOf', [1, 2, 1, 3, 1, 4], 1, 3) a = [4, 3, 2, 1] test('delitem', a, None, 1) -if a <> [4, 2, 1]: +if a != [4, 2, 1]: print 'delitem() failed' a = range(10) test('delslice', a, None, 2, 8) -if a <> [0, 1, 8, 9]: +if a != [0, 1, 8, 9]: print 'delslice() failed' a = range(10) @@ -59,12 +59,12 @@ test('sequenceIncludes', range(4), 1, 2) test('sequenceIncludes', range(4), 0, 5) test('setitem', a, None, 0, 2) -if a <> [2, 1, 2]: +if a != [2, 1, 2]: print 'setitem() failed' a = range(4) test('setslice', a, None, 1, 3, [2, 1]) -if a <> [0, 2, 1, 3]: +if a != [0, 2, 1, 3]: print 'setslice() failed:', a test('sub', 5, 2, 3) diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py index 0ef6cbf..f1e5179 100644 --- a/Lib/test/test_pow.py +++ b/Lib/test/test_pow.py @@ -110,11 +110,11 @@ for i in range(-10, 11): o = pow(i,j) % k n = pow(i,j,k) if o != n: print 'Integer mismatch:', i,j,k - if j >= 0 and k <> 0: + if j >= 0 and k != 0: o = pow(long(i),j) % k n = pow(long(i),j,k) if o != n: print 'Long mismatch:', i,j,k - if i >= 0 and k <> 0: + if i >= 0 and k != 0: o = pow(float(i),j) % k n = pow(float(i),j,k) if o != n: print 'Float mismatch:', i,j,k diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index 53769c0..5ea7e6f 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -81,7 +81,7 @@ else: raise TestFailed, "pty.fork() failed to make child a session leader." elif status / 256 == 3: raise TestFailed, "Child spawned by pty.fork() did not have a tty as stdout" - elif status / 256 <> 4: + elif status / 256 != 4: raise TestFailed, "pty.fork() failed for unknown reasons:" print os.read(master_fd, 65536) diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py index 7e9db21..7425f53 100644 --- a/Lib/test/test_pwd.py +++ b/Lib/test/test_pwd.py @@ -12,11 +12,11 @@ for e in entries: print name, uid print 'pwd.getpwuid()' dbuid = pwd.getpwuid(uid) - if dbuid[0] <> name: + if dbuid[0] != name: print 'Mismatch in pwd.getpwuid()' print 'pwd.getpwnam()' dbname = pwd.getpwnam(name) - if dbname[2] <> uid: + if dbname[2] != uid: print 'Mismatch in pwd.getpwnam()' else: print 'name matches uid' diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 2dfa2bb..4d52c14 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -15,7 +15,7 @@ try: assert re.search('x*', 'axx').span() == (0, 0) assert re.search('x+', 'axx').span(0) == (1, 3) assert re.search('x+', 'axx').span() == (1, 3) - assert re.search('x', 'aaa') == None + assert re.search('x', 'aaa') is None except: raise TestFailed, "re.search" @@ -24,7 +24,7 @@ try: assert re.match('a*', 'xxx').span() == (0, 0) assert re.match('x*', 'xxxa').span(0) == (0, 3) assert re.match('x*', 'xxxa').span() == (0, 3) - assert re.match('a+', 'xxx') == None + assert re.match('a+', 'xxx') is None except: raise TestFailed, "re.search" @@ -216,11 +216,11 @@ try: p="" for i in range(0, 256): p = p + chr(i) - assert re.match(re.escape(chr(i)), chr(i)) != None + assert re.match(re.escape(chr(i)), chr(i)) is not None assert re.match(re.escape(chr(i)), chr(i)).span() == (0,1) pat=re.compile( re.escape(p) ) - assert pat.match(p) != None + assert pat.match(p) is not None assert pat.match(p).span() == (0,256) except AssertionError: raise TestFailed, "re.escape" @@ -335,14 +335,14 @@ for t in tests: # Try the match on a unicode string, and check that it # still succeeds. result = obj.search(unicode(s, "latin-1")) - if result == None: + if result is None: print '=== Fails on unicode match', t # Try the match on a unicode pattern, and check that it # still succeeds. obj=re.compile(unicode(pattern, "latin-1")) result = obj.search(s) - if result == None: + if result is None: print '=== Fails on unicode pattern match', t # Try the match with the search area limited to the extent @@ -351,29 +351,29 @@ for t in tests: # string), so we'll ignore patterns that feature it. if pattern[:2] != '\\B' and pattern[-2:] != '\\B' \ - and result != None: + and result is not None: obj = re.compile(pattern) result = obj.search(s, result.start(0), result.end(0) + 1) - if result == None: + if result is None: print '=== Failed on range-limited match', t # Try the match with IGNORECASE enabled, and check that it # still succeeds. obj = re.compile(pattern, re.IGNORECASE) result = obj.search(s) - if result == None: + if result is None: print '=== Fails on case-insensitive match', t # Try the match with LOCALE enabled, and check that it # still succeeds. obj = re.compile(pattern, re.LOCALE) result = obj.search(s) - if result == None: + if result is None: print '=== Fails on locale-sensitive match', t # Try the match with UNICODE locale enabled, and check # that it still succeeds. obj = re.compile(pattern, re.UNICODE) result = obj.search(s) - if result == None: + if result is None: print '=== Fails on unicode-sensitive match', t diff --git a/Lib/test/test_rotor.py b/Lib/test/test_rotor.py index a5c02aa..28c5af5 100644 --- a/Lib/test/test_rotor.py +++ b/Lib/test/test_rotor.py @@ -13,12 +13,12 @@ print `b` A1 = r.decrypt(a) print A1 -if A1 <> A: +if A1 != A: print 'decrypt failed' B1 = r.decryptmore(b) print B1 -if B1 <> B: +if B1 != B: print 'decryptmore failed' try: diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index b4c840b..e6f2755 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -395,8 +395,8 @@ def test_expat_locator_noinfo(): parser.feed("</doc>") parser.close() - return parser.getSystemId() == None and \ - parser.getPublicId() == None and \ + return parser.getSystemId() is None and \ + parser.getPublicId() is None and \ parser.getLineNumber() == 1 def test_expat_locator_withinfo(): @@ -407,7 +407,7 @@ def test_expat_locator_withinfo(): parser.parse(findfile("test.xml")) return parser.getSystemId() == findfile("test.xml") and \ - parser.getPublicId() == None + parser.getPublicId() is None # =========================================================================== @@ -484,7 +484,7 @@ def verify_empty_attrs(attrs): len(attrs) == 0 and \ not attrs.has_key("attr") and \ attrs.keys() == [] and \ - attrs.get("attrs") == None and \ + attrs.get("attrs") is None and \ attrs.get("attrs", 25) == 25 and \ attrs.items() == [] and \ attrs.values() == [] and \ @@ -552,7 +552,7 @@ def verify_empty_nsattrs(attrs): len(attrs) == 0 and \ not attrs.has_key((ns_uri, "attr")) and \ attrs.keys() == [] and \ - attrs.get((ns_uri, "attr")) == None and \ + attrs.get((ns_uri, "attr")) is None and \ attrs.get((ns_uri, "attr"), 25) == 25 and \ attrs.items() == [] and \ attrs.values() == [] and \ diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 92b9336..fe37936 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -137,7 +137,7 @@ try: msg = 'socket test' s.send(msg) data = s.recv(1024) - if msg <> data: + if msg != data: print 'parent/client mismatch' s.close() finally: diff --git a/Lib/test/test_sre.py b/Lib/test/test_sre.py index b9692a1..9c01c66 100644 --- a/Lib/test/test_sre.py +++ b/Lib/test/test_sre.py @@ -47,12 +47,12 @@ if verbose: print 'Running tests on character literals' for i in [0, 8, 16, 32, 64, 127, 128, 255]: - test(r"""sre.match(r"\%03o" % i, chr(i)) != None""", 1) - test(r"""sre.match(r"\%03o0" % i, chr(i)+"0") != None""", 1) - test(r"""sre.match(r"\%03o8" % i, chr(i)+"8") != None""", 1) - test(r"""sre.match(r"\x%02x" % i, chr(i)) != None""", 1) - test(r"""sre.match(r"\x%02x0" % i, chr(i)+"0") != None""", 1) - test(r"""sre.match(r"\x%02xz" % i, chr(i)+"z") != None""", 1) + test(r"""sre.match(r"\%03o" % i, chr(i)) is not None""", 1) + test(r"""sre.match(r"\%03o0" % i, chr(i)+"0") is not None""", 1) + test(r"""sre.match(r"\%03o8" % i, chr(i)+"8") is not None""", 1) + test(r"""sre.match(r"\x%02x" % i, chr(i)) is not None""", 1) + test(r"""sre.match(r"\x%02x0" % i, chr(i)+"0") is not None""", 1) + test(r"""sre.match(r"\x%02xz" % i, chr(i)+"z") is not None""", 1) test(r"""sre.match("\911", "")""", None, sre.error) # @@ -197,11 +197,11 @@ if verbose: p = "" for i in range(0, 256): p = p + chr(i) - test(r"""sre.match(sre.escape(chr(i)), chr(i)) != None""", 1) + test(r"""sre.match(sre.escape(chr(i)), chr(i)) is not None""", 1) test(r"""sre.match(sre.escape(chr(i)), chr(i)).span()""", (0,1)) pat = sre.compile(sre.escape(p)) -test(r"""pat.match(p) != None""", 1) +test(r"""pat.match(p) is not None""", 1) test(r"""pat.match(p).span()""", (0,256)) if verbose: diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 5892966..c48d92d 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -15,14 +15,14 @@ def simple_err(func, *args): simple_err(struct.calcsize, 'Q') sz = struct.calcsize('i') -if sz * 3 <> struct.calcsize('iii'): +if sz * 3 != struct.calcsize('iii'): raise TestFailed, 'inconsistent sizes' fmt = 'cbxxxxxxhhhhiillffd' fmt3 = '3c3b18x12h6i6l6f3d' sz = struct.calcsize(fmt) sz3 = struct.calcsize(fmt3) -if sz * 3 <> sz3: +if sz * 3 != sz3: raise TestFailed, 'inconsistent sizes (3*%s -> 3*%d = %d, %s -> %d)' % ( `fmt`, sz, 3*sz, `fmt3`, sz3) @@ -49,8 +49,8 @@ for prefix in ('', '@', '<', '>', '=', '!'): print "trying:", format s = struct.pack(format, c, b, h, i, l, f, d) cp, bp, hp, ip, lp, fp, dp = struct.unpack(format, s) - if (cp <> c or bp <> b or hp <> h or ip <> i or lp <> l or - int(100 * fp) <> int(100 * f) or int(100 * dp) <> int(100 * d)): + if (cp != c or bp != b or hp != h or ip != i or lp != l or + int(100 * fp) != int(100 * f) or int(100 * dp) != int(100 * d)): # ^^^ calculate only to two decimal places raise TestFailed, "unpack/pack not transitive (%s, %s)" % ( str(format), str((cp, bp, hp, ip, lp, fp, dp))) diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 4f78b4c..a24b3ce 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -52,7 +52,7 @@ def fcmp(x, y): # fuzzy comparison function elif type(x) == type(y) and type(x) in (type(()), type([])): for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) - if outcome <> 0: + if outcome != 0: return outcome return cmp(len(x), len(y)) return cmp(x, y) diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 03d081e..ebe8fa7 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -4,12 +4,12 @@ time.altzone time.clock() t = time.time() time.asctime(time.gmtime(t)) -if time.ctime(t) <> time.asctime(time.localtime(t)): - print 'time.ctime(t) <> time.asctime(time.localtime(t))' +if time.ctime(t) != time.asctime(time.localtime(t)): + print 'time.ctime(t) != time.asctime(time.localtime(t))' time.daylight -if long(time.mktime(time.localtime(t))) <> long(t): - print 'time.mktime(time.localtime(t)) <> t' +if long(time.mktime(time.localtime(t))) != long(t): + print 'time.mktime(time.localtime(t)) != t' time.sleep(1.2) tt = time.gmtime(t) diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index cf4f6b4..bf35687 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -36,11 +36,11 @@ else: raise TestFailed, '1 and 1 is false instead of false' if not 1: raise TestFailed, 'not 1 is true instead of false' print '6.3 Comparisons' -if 0 < 1 <= 1 == 1 >= 1 > 0 <> 1: pass +if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass else: raise TestFailed, 'int comparisons failed' -if 0L < 1L <= 1L == 1L >= 1L > 0L <> 1L: pass +if 0L < 1L <= 1L == 1L >= 1L > 0L != 1L: pass else: raise TestFailed, 'long int comparisons failed' -if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 <> 1.0: pass +if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass else: raise TestFailed, 'float comparisons failed' if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass else: raise TestFailed, 'string comparisons failed' @@ -50,9 +50,9 @@ if None is None and [] is not []: pass else: raise TestFailed, 'identity test failed' print '6.4 Numeric types (mostly conversions)' -if 0 <> 0L or 0 <> 0.0 or 0L <> 0.0: raise TestFailed, 'mixed comparisons' -if 1 <> 1L or 1 <> 1.0 or 1L <> 1.0: raise TestFailed, 'mixed comparisons' -if -1 <> -1L or -1 <> -1.0 or -1L <> -1.0: +if 0 != 0L or 0 != 0.0 or 0L != 0.0: raise TestFailed, 'mixed comparisons' +if 1 != 1L or 1 != 1.0 or 1L != 1.0: raise TestFailed, 'mixed comparisons' +if -1 != -1L or -1 != -1.0 or -1L != -1.0: raise TestFailed, 'int/long/float value not equal' if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass else: raise TestFailed, 'int() does not round properly' @@ -61,10 +61,10 @@ else: raise TestFailed, 'long() does not round properly' if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass else: raise TestFailed, 'float() does not work properly' print '6.4.1 32-bit integers' -if 12 + 24 <> 36: raise TestFailed, 'int op' -if 12 + (-24) <> -12: raise TestFailed, 'int op' -if (-12) + 24 <> 12: raise TestFailed, 'int op' -if (-12) + (-24) <> -36: raise TestFailed, 'int op' +if 12 + 24 != 36: raise TestFailed, 'int op' +if 12 + (-24) != -12: raise TestFailed, 'int op' +if (-12) + 24 != 12: raise TestFailed, 'int op' +if (-12) + (-24) != -36: raise TestFailed, 'int op' if not 12 < 24: raise TestFailed, 'int op' if not -24 < -12: raise TestFailed, 'int op' # Test for a particular bug in integer multiply @@ -72,10 +72,10 @@ xsize, ysize, zsize = 238, 356, 4 if not (xsize*ysize*zsize == zsize*xsize*ysize == 338912): raise TestFailed, 'int mul commutativity' print '6.4.2 Long integers' -if 12L + 24L <> 36L: raise TestFailed, 'long op' -if 12L + (-24L) <> -12L: raise TestFailed, 'long op' -if (-12L) + 24L <> 12L: raise TestFailed, 'long op' -if (-12L) + (-24L) <> -36L: raise TestFailed, 'long op' +if 12L + 24L != 36L: raise TestFailed, 'long op' +if 12L + (-24L) != -12L: raise TestFailed, 'long op' +if (-12L) + 24L != 12L: raise TestFailed, 'long op' +if (-12L) + (-24L) != -36L: raise TestFailed, 'long op' if not 12L < 24L: raise TestFailed, 'long op' if not -24L < -12L: raise TestFailed, 'long op' x = sys.maxint @@ -91,49 +91,49 @@ try: int(long(x)-1L) except OverflowError: pass else:raise TestFailed, 'long op' print '6.4.3 Floating point numbers' -if 12.0 + 24.0 <> 36.0: raise TestFailed, 'float op' -if 12.0 + (-24.0) <> -12.0: raise TestFailed, 'float op' -if (-12.0) + 24.0 <> 12.0: raise TestFailed, 'float op' -if (-12.0) + (-24.0) <> -36.0: raise TestFailed, 'float op' +if 12.0 + 24.0 != 36.0: raise TestFailed, 'float op' +if 12.0 + (-24.0) != -12.0: raise TestFailed, 'float op' +if (-12.0) + 24.0 != 12.0: raise TestFailed, 'float op' +if (-12.0) + (-24.0) != -36.0: raise TestFailed, 'float op' if not 12.0 < 24.0: raise TestFailed, 'float op' if not -24.0 < -12.0: raise TestFailed, 'float op' print '6.5 Sequence types' print '6.5.1 Strings' -if len('') <> 0: raise TestFailed, 'len(\'\')' -if len('a') <> 1: raise TestFailed, 'len(\'a\')' -if len('abcdef') <> 6: raise TestFailed, 'len(\'abcdef\')' -if 'xyz' + 'abcde' <> 'xyzabcde': raise TestFailed, 'string concatenation' -if 'xyz'*3 <> 'xyzxyzxyz': raise TestFailed, 'string repetition *3' -if 0*'abcde' <> '': raise TestFailed, 'string repetition 0*' -if min('abc') <> 'a' or max('abc') <> 'c': raise TestFailed, 'min/max string' +if len('') != 0: raise TestFailed, 'len(\'\')' +if len('a') != 1: raise TestFailed, 'len(\'a\')' +if len('abcdef') != 6: raise TestFailed, 'len(\'abcdef\')' +if 'xyz' + 'abcde' != 'xyzabcde': raise TestFailed, 'string concatenation' +if 'xyz'*3 != 'xyzxyzxyz': raise TestFailed, 'string repetition *3' +if 0*'abcde' != '': raise TestFailed, 'string repetition 0*' +if min('abc') != 'a' or max('abc') != 'c': raise TestFailed, 'min/max string' if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass else: raise TestFailed, 'in/not in string' x = 'x'*103 if '%s!'%x != x+'!': raise TestFailed, 'nasty string formatting bug' print '6.5.2 Tuples' -if len(()) <> 0: raise TestFailed, 'len(())' -if len((1,)) <> 1: raise TestFailed, 'len((1,))' -if len((1,2,3,4,5,6)) <> 6: raise TestFailed, 'len((1,2,3,4,5,6))' -if (1,2)+(3,4) <> (1,2,3,4): raise TestFailed, 'tuple concatenation' -if (1,2)*3 <> (1,2,1,2,1,2): raise TestFailed, 'tuple repetition *3' -if 0*(1,2,3) <> (): raise TestFailed, 'tuple repetition 0*' -if min((1,2)) <> 1 or max((1,2)) <> 2: raise TestFailed, 'min/max tuple' +if len(()) != 0: raise TestFailed, 'len(())' +if len((1,)) != 1: raise TestFailed, 'len((1,))' +if len((1,2,3,4,5,6)) != 6: raise TestFailed, 'len((1,2,3,4,5,6))' +if (1,2)+(3,4) != (1,2,3,4): raise TestFailed, 'tuple concatenation' +if (1,2)*3 != (1,2,1,2,1,2): raise TestFailed, 'tuple repetition *3' +if 0*(1,2,3) != (): raise TestFailed, 'tuple repetition 0*' +if min((1,2)) != 1 or max((1,2)) != 2: raise TestFailed, 'min/max tuple' if 0 in (0,1,2) and 1 in (0,1,2) and 2 in (0,1,2) and 3 not in (0,1,2): pass else: raise TestFailed, 'in/not in tuple' print '6.5.3 Lists' -if len([]) <> 0: raise TestFailed, 'len([])' -if len([1,]) <> 1: raise TestFailed, 'len([1,])' -if len([1,2,3,4,5,6]) <> 6: raise TestFailed, 'len([1,2,3,4,5,6])' -if [1,2]+[3,4] <> [1,2,3,4]: raise TestFailed, 'list concatenation' -if [1,2]*3 <> [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3' -if [1,2]*3L <> [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3L' -if 0*[1,2,3] <> []: raise TestFailed, 'list repetition 0*' -if 0L*[1,2,3] <> []: raise TestFailed, 'list repetition 0L*' -if min([1,2]) <> 1 or max([1,2]) <> 2: raise TestFailed, 'min/max list' +if len([]) != 0: raise TestFailed, 'len([])' +if len([1,]) != 1: raise TestFailed, 'len([1,])' +if len([1,2,3,4,5,6]) != 6: raise TestFailed, 'len([1,2,3,4,5,6])' +if [1,2]+[3,4] != [1,2,3,4]: raise TestFailed, 'list concatenation' +if [1,2]*3 != [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3' +if [1,2]*3L != [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3L' +if 0*[1,2,3] != []: raise TestFailed, 'list repetition 0*' +if 0L*[1,2,3] != []: raise TestFailed, 'list repetition 0L*' +if min([1,2]) != 1 or max([1,2]) != 2: raise TestFailed, 'min/max list' if 0 in [0,1,2] and 1 in [0,1,2] and 2 in [0,1,2] and 3 not in [0,1,2]: pass else: raise TestFailed, 'in/not in list' a = [1, 2, 3, 4, 5] @@ -155,55 +155,55 @@ a = [0,1,2,3,4] a[0L] = 1 a[1L] = 2 a[2L] = 3 -if a <> [1,2,3,3,4]: raise TestFailed, 'list item assignment [0L], [1L], [2L]' +if a != [1,2,3,3,4]: raise TestFailed, 'list item assignment [0L], [1L], [2L]' a[0] = 5 a[1] = 6 a[2] = 7 -if a <> [5,6,7,3,4]: raise TestFailed, 'list item assignment [0], [1], [2]' +if a != [5,6,7,3,4]: raise TestFailed, 'list item assignment [0], [1], [2]' a[-2L] = 88 a[-1L] = 99 -if a <> [5,6,7,88,99]: raise TestFailed, 'list item assignment [-2L], [-1L]' +if a != [5,6,7,88,99]: raise TestFailed, 'list item assignment [-2L], [-1L]' a[-2] = 8 a[-1] = 9 -if a <> [5,6,7,8,9]: raise TestFailed, 'list item assignment [-2], [-1]' +if a != [5,6,7,8,9]: raise TestFailed, 'list item assignment [-2], [-1]' a[:2] = [0,4] a[-3:] = [] a[1:1] = [1,2,3] -if a <> [0,1,2,3,4]: raise TestFailed, 'list slice assignment' +if a != [0,1,2,3,4]: raise TestFailed, 'list slice assignment' a[ 1L : 4L] = [7,8,9] -if a <> [0,7,8,9,4]: raise TestFailed, 'list slice assignment using long ints' +if a != [0,7,8,9,4]: raise TestFailed, 'list slice assignment using long ints' del a[1:4] -if a <> [0,4]: raise TestFailed, 'list slice deletion' +if a != [0,4]: raise TestFailed, 'list slice deletion' del a[0] -if a <> [4]: raise TestFailed, 'list item deletion [0]' +if a != [4]: raise TestFailed, 'list item deletion [0]' del a[-1] -if a <> []: raise TestFailed, 'list item deletion [-1]' +if a != []: raise TestFailed, 'list item deletion [-1]' a=range(0,5) del a[1L:4L] -if a <> [0,4]: raise TestFailed, 'list slice deletion' +if a != [0,4]: raise TestFailed, 'list slice deletion' del a[0L] -if a <> [4]: raise TestFailed, 'list item deletion [0]' +if a != [4]: raise TestFailed, 'list item deletion [0]' del a[-1L] -if a <> []: raise TestFailed, 'list item deletion [-1]' +if a != []: raise TestFailed, 'list item deletion [-1]' a.append(0) a.append(1) a.append(2) -if a <> [0,1,2]: raise TestFailed, 'list append' +if a != [0,1,2]: raise TestFailed, 'list append' a.insert(0, -2) a.insert(1, -1) a.insert(2,0) -if a <> [-2,-1,0,0,1,2]: raise TestFailed, 'list insert' -if a.count(0) <> 2: raise TestFailed, ' list count' -if a.index(0) <> 2: raise TestFailed, 'list index' +if a != [-2,-1,0,0,1,2]: raise TestFailed, 'list insert' +if a.count(0) != 2: raise TestFailed, ' list count' +if a.index(0) != 2: raise TestFailed, 'list index' a.remove(0) -if a <> [-2,-1,0,1,2]: raise TestFailed, 'list remove' +if a != [-2,-1,0,1,2]: raise TestFailed, 'list remove' a.reverse() -if a <> [2,1,0,-1,-2]: raise TestFailed, 'list reverse' +if a != [2,1,0,-1,-2]: raise TestFailed, 'list reverse' a.sort() -if a <> [-2,-1,0,1,2]: raise TestFailed, 'list sort' +if a != [-2,-1,0,1,2]: raise TestFailed, 'list sort' def revcmp(a, b): return cmp(b, a) a.sort(revcmp) -if a <> [2,1,0,-1,-2]: raise TestFailed, 'list sort with cmp func' +if a != [2,1,0,-1,-2]: raise TestFailed, 'list sort with cmp func' # The following dumps core in unpatched Python 1.5: def myComparison(x,y): return cmp(x%3, y%7) @@ -219,22 +219,22 @@ if a[ 3: pow(2,145L) ] != [3,4]: print '6.6 Mappings == Dictionaries' d = {} -if d.keys() <> []: raise TestFailed, '{}.keys()' -if d.has_key('a') <> 0: raise TestFailed, '{}.has_key(\'a\')' -if len(d) <> 0: raise TestFailed, 'len({})' +if d.keys() != []: raise TestFailed, '{}.keys()' +if d.has_key('a') != 0: raise TestFailed, '{}.has_key(\'a\')' +if len(d) != 0: raise TestFailed, 'len({})' d = {'a': 1, 'b': 2} -if len(d) <> 2: raise TestFailed, 'len(dict)' +if len(d) != 2: raise TestFailed, 'len(dict)' k = d.keys() k.sort() -if k <> ['a', 'b']: raise TestFailed, 'dict keys()' +if k != ['a', 'b']: raise TestFailed, 'dict keys()' if d.has_key('a') and d.has_key('b') and not d.has_key('c'): pass else: raise TestFailed, 'dict keys()' -if d['a'] <> 1 or d['b'] <> 2: raise TestFailed, 'dict item' +if d['a'] != 1 or d['b'] != 2: raise TestFailed, 'dict item' d['c'] = 3 d['a'] = 4 -if d['c'] <> 3 or d['a'] <> 4: raise TestFailed, 'dict item assignment' +if d['c'] != 3 or d['a'] != 4: raise TestFailed, 'dict item assignment' del d['b'] -if d <> {'a': 4, 'c': 3}: raise TestFailed, 'dict item deletion' +if d != {'a': 4, 'c': 3}: raise TestFailed, 'dict item deletion' d = {1:1, 2:2, 3:3} d.clear() if d != {}: raise TestFailed, 'dict clear' @@ -246,24 +246,24 @@ if d.copy() != {1:1, 2:2, 3:3}: raise TestFailed, 'dict copy' if {}.copy() != {}: raise TestFailed, 'empty dict copy' # dict.get() d = {} -if d.get('c') != None: raise TestFailed, 'missing {} get, no 2nd arg' +if d.get('c') is not None: raise TestFailed, 'missing {} get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing {} get, w/ 2nd arg' d = {'a' : 1, 'b' : 2} -if d.get('c') != None: raise TestFailed, 'missing dict get, no 2nd arg' +if d.get('c') is not None: raise TestFailed, 'missing dict get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing dict get, w/ 2nd arg' if d.get('a') != 1: raise TestFailed, 'present dict get, no 2nd arg' if d.get('a', 3) != 1: raise TestFailed, 'present dict get, w/ 2nd arg' # dict.setdefault() d = {} -if d.setdefault('key0') <> None: +if d.setdefault('key0') is not None: raise TestFailed, 'missing {} setdefault, no 2nd arg' -if d.setdefault('key0') <> None: +if d.setdefault('key0') is not None: raise TestFailed, 'present {} setdefault, no 2nd arg' d.setdefault('key', []).append(3) -if d['key'][0] <> 3: +if d['key'][0] != 3: raise TestFailed, 'missing {} setdefault, w/ 2nd arg' d.setdefault('key', []).append(4) -if len(d['key']) <> 2: +if len(d['key']) != 2: raise TestFailed, 'present {} setdefault, w/ 2nd arg' # dict.popitem() for copymode in -1, +1: diff --git a/Lib/test/test_unpack.py b/Lib/test/test_unpack.py index 25b94e9..b913b9e 100644 --- a/Lib/test/test_unpack.py +++ b/Lib/test/test_unpack.py @@ -16,35 +16,35 @@ c = -1 if verbose: print 'unpack tuple' a, b, c = t -if a <> 1 or b <> 2 or c <> 3: +if a != 1 or b != 2 or c != 3: raise TestFailed # unpack list if verbose: print 'unpack list' a, b, c = l -if a <> 4 or b <> 5 or c <> 6: +if a != 4 or b != 5 or c != 6: raise TestFailed # unpack implied tuple if verbose: print 'unpack implied tuple' a, b, c = 7, 8, 9 -if a <> 7 or b <> 8 or c <> 9: +if a != 7 or b != 8 or c != 9: raise TestFailed # unpack string... fun! if verbose: print 'unpack string' a, b, c = 'one' -if a <> 'o' or b <> 'n' or c <> 'e': +if a != 'o' or b != 'n' or c != 'e': raise TestFailed # unpack generic sequence if verbose: print 'unpack sequence' a, b, c = Seq() -if a <> 0 or b <> 1 or c <> 2: +if a != 0 or b != 1 or c != 2: raise TestFailed # single element unpacking, with extra syntax @@ -53,10 +53,10 @@ if verbose: st = (99,) sl = [100] a, = st -if a <> 99: +if a != 99: raise TestFailed b, = sl -if b <> 100: +if b != 100: raise TestFailed # now for some failures |