blob: 1a21689ef81224553be470cf3ce3f50ceee2fdfe [file] [log] [blame]
Guido van Rossum3bead091992-01-27 17:00:37 +00001# Python test set -- part 4b, built-in functions n-z
2
3from test_support import *
4
5print 'oct'
6if oct(100) != '0144': raise TestFailed, 'oct(100)'
7if oct(100L) != '0144L': raise TestFailed, 'oct(100L)'
Guido van Rossumd9c6f4f1997-06-06 21:14:14 +00008if oct(-100) not in ('037777777634', '01777777777777777777634'):
Fred Drake004d5e62000-10-23 17:22:08 +00009 raise TestFailed, 'oct(-100)'
Guido van Rossum3bead091992-01-27 17:00:37 +000010if oct(-100L) != '-0144L': raise TestFailed, 'oct(-100L)'
11
12print 'open'
13# NB the first 4 lines are also used to test input and raw_input, below
14fp = open(TESTFN, 'w')
15try:
Fred Drake004d5e62000-10-23 17:22:08 +000016 fp.write('1+1\n')
17 fp.write('1+1\n')
18 fp.write('The quick brown fox jumps over the lazy dog')
19 fp.write('.\n')
20 fp.write('Dear John\n')
21 fp.write('XXX'*100)
22 fp.write('YYY'*100)
Guido van Rossum3bead091992-01-27 17:00:37 +000023finally:
Fred Drake004d5e62000-10-23 17:22:08 +000024 fp.close()
Guido van Rossum3bead091992-01-27 17:00:37 +000025#
26fp = open(TESTFN, 'r')
27try:
Fred Drake132dce22000-12-12 23:11:42 +000028 if fp.readline(4) != '1+1\n': raise TestFailed, 'readline(4) # exact'
29 if fp.readline(4) != '1+1\n': raise TestFailed, 'readline(4) # exact'
30 if fp.readline() != 'The quick brown fox jumps over the lazy dog.\n':
Fred Drake004d5e62000-10-23 17:22:08 +000031 raise TestFailed, 'readline() # default'
Fred Drake132dce22000-12-12 23:11:42 +000032 if fp.readline(4) != 'Dear': raise TestFailed, 'readline(4) # short'
33 if fp.readline(100) != ' John\n': raise TestFailed, 'readline(100)'
34 if fp.read(300) != 'XXX'*100: raise TestFailed, 'read(300)'
35 if fp.read(1000) != 'YYY'*100: raise TestFailed, 'read(1000) # truncate'
Guido van Rossum3bead091992-01-27 17:00:37 +000036finally:
Fred Drake004d5e62000-10-23 17:22:08 +000037 fp.close()
Guido van Rossum3bead091992-01-27 17:00:37 +000038
39print 'ord'
Fred Drake132dce22000-12-12 23:11:42 +000040if ord(' ') != 32: raise TestFailed, 'ord(\' \')'
41if ord('A') != 65: raise TestFailed, 'ord(\'A\')'
42if ord('a') != 97: raise TestFailed, 'ord(\'a\')'
Guido van Rossum3bead091992-01-27 17:00:37 +000043
44print 'pow'
Fred Drake132dce22000-12-12 23:11:42 +000045if pow(0,0) != 1: raise TestFailed, 'pow(0,0)'
46if pow(0,1) != 0: raise TestFailed, 'pow(0,1)'
47if pow(1,0) != 1: raise TestFailed, 'pow(1,0)'
48if pow(1,1) != 1: raise TestFailed, 'pow(1,1)'
Guido van Rossum3bead091992-01-27 17:00:37 +000049#
Fred Drake132dce22000-12-12 23:11:42 +000050if pow(2,0) != 1: raise TestFailed, 'pow(2,0)'
51if pow(2,10) != 1024: raise TestFailed, 'pow(2,10)'
52if pow(2,20) != 1024*1024: raise TestFailed, 'pow(2,20)'
53if pow(2,30) != 1024*1024*1024: raise TestFailed, 'pow(2,30)'
Guido van Rossum3bead091992-01-27 17:00:37 +000054#
Fred Drake132dce22000-12-12 23:11:42 +000055if pow(-2,0) != 1: raise TestFailed, 'pow(-2,0)'
56if pow(-2,1) != -2: raise TestFailed, 'pow(-2,1)'
57if pow(-2,2) != 4: raise TestFailed, 'pow(-2,2)'
58if pow(-2,3) != -8: raise TestFailed, 'pow(-2,3)'
Guido van Rossum3bead091992-01-27 17:00:37 +000059#
Fred Drake132dce22000-12-12 23:11:42 +000060if pow(0L,0) != 1: raise TestFailed, 'pow(0L,0)'
61if pow(0L,1) != 0: raise TestFailed, 'pow(0L,1)'
62if pow(1L,0) != 1: raise TestFailed, 'pow(1L,0)'
63if pow(1L,1) != 1: raise TestFailed, 'pow(1L,1)'
Guido van Rossum3bead091992-01-27 17:00:37 +000064#
Fred Drake132dce22000-12-12 23:11:42 +000065if pow(2L,0) != 1: raise TestFailed, 'pow(2L,0)'
66if pow(2L,10) != 1024: raise TestFailed, 'pow(2L,10)'
67if pow(2L,20) != 1024*1024: raise TestFailed, 'pow(2L,20)'
68if pow(2L,30) != 1024*1024*1024: raise TestFailed, 'pow(2L,30)'
Guido van Rossum3bead091992-01-27 17:00:37 +000069#
Fred Drake132dce22000-12-12 23:11:42 +000070if pow(-2L,0) != 1: raise TestFailed, 'pow(-2L,0)'
71if pow(-2L,1) != -2: raise TestFailed, 'pow(-2L,1)'
72if pow(-2L,2) != 4: raise TestFailed, 'pow(-2L,2)'
73if pow(-2L,3) != -8: raise TestFailed, 'pow(-2L,3)'
Guido van Rossum3bead091992-01-27 17:00:37 +000074#
Guido van Rossum35fb82a1993-01-26 13:04:43 +000075if fcmp(pow(0.,0), 1.): raise TestFailed, 'pow(0.,0)'
76if fcmp(pow(0.,1), 0.): raise TestFailed, 'pow(0.,1)'
77if fcmp(pow(1.,0), 1.): raise TestFailed, 'pow(1.,0)'
78if fcmp(pow(1.,1), 1.): raise TestFailed, 'pow(1.,1)'
Guido van Rossum3bead091992-01-27 17:00:37 +000079#
Guido van Rossum35fb82a1993-01-26 13:04:43 +000080if fcmp(pow(2.,0), 1.): raise TestFailed, 'pow(2.,0)'
81if fcmp(pow(2.,10), 1024.): raise TestFailed, 'pow(2.,10)'
82if fcmp(pow(2.,20), 1024.*1024.): raise TestFailed, 'pow(2.,20)'
83if fcmp(pow(2.,30), 1024.*1024.*1024.): raise TestFailed, 'pow(2.,30)'
Guido van Rossum3bead091992-01-27 17:00:37 +000084#
Tim Peters32f453e2001-09-03 08:35:41 +000085if fcmp(pow(-2.,0), 1.): raise TestFailed, 'pow(-2.,0)'
86if fcmp(pow(-2.,1), -2.): raise TestFailed, 'pow(-2.,1)'
87if fcmp(pow(-2.,2), 4.): raise TestFailed, 'pow(-2.,2)'
88if fcmp(pow(-2.,3), -8.): raise TestFailed, 'pow(-2.,3)'
89
90from types import FloatType
Guido van Rossume23b62f1994-11-10 22:25:26 +000091for x in 2, 2L, 2.0:
Fred Drake004d5e62000-10-23 17:22:08 +000092 for y in 10, 10L, 10.0:
93 for z in 1000, 1000L, 1000.0:
Tim Peters32f453e2001-09-03 08:35:41 +000094 if isinstance(x, FloatType) or \
95 isinstance(y, FloatType) or \
96 isinstance(z, FloatType):
97 try:
98 pow(x, y, z)
99 except TypeError:
100 pass
101 else:
102 raise TestFailed("3-arg float pow() should have "
103 "raised TypeError %r" % (x, y, z))
104 else:
105 if fcmp(pow(x, y, z), 24.0):
106 raise TestFailed, 'pow(%s, %s, %s)' % (x, y, z)
Guido van Rossum3bead091992-01-27 17:00:37 +0000107
108print 'range'
Fred Drake132dce22000-12-12 23:11:42 +0000109if range(3) != [0, 1, 2]: raise TestFailed, 'range(3)'
110if range(1, 5) != [1, 2, 3, 4]: raise TestFailed, 'range(1, 5)'
111if range(0) != []: raise TestFailed, 'range(0)'
112if range(-3) != []: raise TestFailed, 'range(-3)'
113if range(1, 10, 3) != [1, 4, 7]: raise TestFailed, 'range(1, 10, 3)'
114if range(5, -5, -3) != [5, 2, -1, -4]: raise TestFailed, 'range(5, -5, -3)'
Guido van Rossum3bead091992-01-27 17:00:37 +0000115
116print 'input and raw_input'
117import sys
118fp = open(TESTFN, 'r')
119savestdin = sys.stdin
120try:
Fred Drake004d5e62000-10-23 17:22:08 +0000121 sys.stdin = fp
Fred Drake132dce22000-12-12 23:11:42 +0000122 if input() != 2: raise TestFailed, 'input()'
123 if input('testing\n') != 2: raise TestFailed, 'input()'
124 if raw_input() != 'The quick brown fox jumps over the lazy dog.':
Fred Drake004d5e62000-10-23 17:22:08 +0000125 raise TestFailed, 'raw_input()'
Fred Drake132dce22000-12-12 23:11:42 +0000126 if raw_input('testing\n') != 'Dear John':
Fred Drake004d5e62000-10-23 17:22:08 +0000127 raise TestFailed, 'raw_input(\'testing\\n\')'
Guido van Rossum3bead091992-01-27 17:00:37 +0000128finally:
Fred Drake004d5e62000-10-23 17:22:08 +0000129 sys.stdin = savestdin
130 fp.close()
Guido van Rossum3bead091992-01-27 17:00:37 +0000131
Guido van Rossume65cce51993-11-08 15:05:21 +0000132print 'reduce'
Fred Drake132dce22000-12-12 23:11:42 +0000133if reduce(lambda x, y: x+y, ['a', 'b', 'c'], '') != 'abc':
Fred Drake004d5e62000-10-23 17:22:08 +0000134 raise TestFailed, 'reduce(): implode a string'
Guido van Rossumae3b3a31993-11-30 13:43:54 +0000135if reduce(lambda x, y: x+y,
Fred Drake132dce22000-12-12 23:11:42 +0000136 [['a', 'c'], [], ['d', 'w']], []) != ['a','c','d','w']:
Fred Drake004d5e62000-10-23 17:22:08 +0000137 raise TestFailed, 'reduce(): append'
Fred Drake132dce22000-12-12 23:11:42 +0000138if reduce(lambda x, y: x*y, range(2,8), 1) != 5040:
Fred Drake004d5e62000-10-23 17:22:08 +0000139 raise TestFailed, 'reduce(): compute 7!'
Fred Drake132dce22000-12-12 23:11:42 +0000140if reduce(lambda x, y: x*y, range(2,21), 1L) != 2432902008176640000L:
Fred Drake004d5e62000-10-23 17:22:08 +0000141 raise TestFailed, 'reduce(): compute 20!, use long'
Guido van Rossumb6775db1994-08-01 11:34:53 +0000142class Squares:
Fred Drake004d5e62000-10-23 17:22:08 +0000143 def __init__(self, max):
144 self.max = max
145 self.sofar = []
146 def __len__(self): return len(self.sofar)
147 def __getitem__(self, i):
148 if not 0 <= i < self.max: raise IndexError
149 n = len(self.sofar)
150 while n <= i:
151 self.sofar.append(n*n)
152 n = n+1
153 return self.sofar[i]
Guido van Rossumb6775db1994-08-01 11:34:53 +0000154if reduce(lambda x, y: x+y, Squares(10)) != 285:
Fred Drake004d5e62000-10-23 17:22:08 +0000155 raise TestFailed, 'reduce(<+>, Squares(10))'
Guido van Rossumb6775db1994-08-01 11:34:53 +0000156if reduce(lambda x, y: x+y, Squares(10), 0) != 285:
Fred Drake004d5e62000-10-23 17:22:08 +0000157 raise TestFailed, 'reduce(<+>, Squares(10), 0)'
Guido van Rossumb6775db1994-08-01 11:34:53 +0000158if reduce(lambda x, y: x+y, Squares(0), 0) != 0:
Fred Drake004d5e62000-10-23 17:22:08 +0000159 raise TestFailed, 'reduce(<+>, Squares(0), 0)'
Guido van Rossumb6775db1994-08-01 11:34:53 +0000160
Guido van Rossume65cce51993-11-08 15:05:21 +0000161
Guido van Rossum3bead091992-01-27 17:00:37 +0000162print 'reload'
Guido van Rossumeecf0351994-12-30 17:17:46 +0000163import marshal
164reload(marshal)
Guido van Rossum3bead091992-01-27 17:00:37 +0000165import string
166reload(string)
Guido van Rossum7995ed21997-08-02 03:19:26 +0000167## import sys
168## try: reload(sys)
169## except ImportError: pass
170## else: raise TestFailed, 'reload(sys) should fail'
Guido van Rossum3bead091992-01-27 17:00:37 +0000171
Guido van Rossum85f18201992-11-27 22:53:50 +0000172print 'repr'
Fred Drake132dce22000-12-12 23:11:42 +0000173if repr('') != '\'\'': raise TestFailed, 'repr(\'\')'
174if repr(0) != '0': raise TestFailed, 'repr(0)'
175if repr(0L) != '0L': raise TestFailed, 'repr(0L)'
176if repr(()) != '()': raise TestFailed, 'repr(())'
177if repr([]) != '[]': raise TestFailed, 'repr([])'
178if repr({}) != '{}': raise TestFailed, 'repr({})'
Guido van Rossum85f18201992-11-27 22:53:50 +0000179
Guido van Rossume7113b61993-03-29 11:30:50 +0000180print 'round'
Fred Drake132dce22000-12-12 23:11:42 +0000181if round(0.0) != 0.0: raise TestFailed, 'round(0.0)'
182if round(1.0) != 1.0: raise TestFailed, 'round(1.0)'
183if round(10.0) != 10.0: raise TestFailed, 'round(10.0)'
184if round(1000000000.0) != 1000000000.0:
Fred Drake004d5e62000-10-23 17:22:08 +0000185 raise TestFailed, 'round(1000000000.0)'
Fred Drake132dce22000-12-12 23:11:42 +0000186if round(1e20) != 1e20: raise TestFailed, 'round(1e20)'
Guido van Rossume7113b61993-03-29 11:30:50 +0000187
Fred Drake132dce22000-12-12 23:11:42 +0000188if round(-1.0) != -1.0: raise TestFailed, 'round(-1.0)'
189if round(-10.0) != -10.0: raise TestFailed, 'round(-10.0)'
190if round(-1000000000.0) != -1000000000.0:
Fred Drake004d5e62000-10-23 17:22:08 +0000191 raise TestFailed, 'round(-1000000000.0)'
Fred Drake132dce22000-12-12 23:11:42 +0000192if round(-1e20) != -1e20: raise TestFailed, 'round(-1e20)'
Guido van Rossume7113b61993-03-29 11:30:50 +0000193
Fred Drake132dce22000-12-12 23:11:42 +0000194if round(0.1) != 0.0: raise TestFailed, 'round(0.0)'
195if round(1.1) != 1.0: raise TestFailed, 'round(1.0)'
196if round(10.1) != 10.0: raise TestFailed, 'round(10.0)'
197if round(1000000000.1) != 1000000000.0:
Fred Drake004d5e62000-10-23 17:22:08 +0000198 raise TestFailed, 'round(1000000000.0)'
Guido van Rossume7113b61993-03-29 11:30:50 +0000199
Fred Drake132dce22000-12-12 23:11:42 +0000200if round(-1.1) != -1.0: raise TestFailed, 'round(-1.0)'
201if round(-10.1) != -10.0: raise TestFailed, 'round(-10.0)'
202if round(-1000000000.1) != -1000000000.0:
Fred Drake004d5e62000-10-23 17:22:08 +0000203 raise TestFailed, 'round(-1000000000.0)'
Guido van Rossume7113b61993-03-29 11:30:50 +0000204
Fred Drake132dce22000-12-12 23:11:42 +0000205if round(0.9) != 1.0: raise TestFailed, 'round(0.9)'
206if round(9.9) != 10.0: raise TestFailed, 'round(9.9)'
207if round(999999999.9) != 1000000000.0:
Fred Drake004d5e62000-10-23 17:22:08 +0000208 raise TestFailed, 'round(999999999.9)'
Guido van Rossume7113b61993-03-29 11:30:50 +0000209
Fred Drake132dce22000-12-12 23:11:42 +0000210if round(-0.9) != -1.0: raise TestFailed, 'round(-0.9)'
211if round(-9.9) != -10.0: raise TestFailed, 'round(-9.9)'
212if round(-999999999.9) != -1000000000.0:
Fred Drake004d5e62000-10-23 17:22:08 +0000213 raise TestFailed, 'round(-999999999.9)'
Guido van Rossume7113b61993-03-29 11:30:50 +0000214
Guido van Rossum3bead091992-01-27 17:00:37 +0000215print 'setattr'
216import sys
Guido van Rossume23b62f1994-11-10 22:25:26 +0000217setattr(sys, 'spam', 1)
218if sys.spam != 1: raise TestFailed, 'setattr(sys, \'spam\', 1)'
Jeremy Hyltonb7a77312001-07-30 22:49:11 +0000219try:
220 setattr(sys, 1, 'spam')
221except TypeError:
222 pass
223else:
224 raise TestFailed, "setattr(sys, 1, 'spam') should raise exception"
Guido van Rossum3bead091992-01-27 17:00:37 +0000225
Guido van Rossum85f18201992-11-27 22:53:50 +0000226print 'str'
Fred Drake132dce22000-12-12 23:11:42 +0000227if str('') != '': raise TestFailed, 'str(\'\')'
228if str(0) != '0': raise TestFailed, 'str(0)'
229if str(0L) != '0': raise TestFailed, 'str(0L)'
230if str(()) != '()': raise TestFailed, 'str(())'
231if str([]) != '[]': raise TestFailed, 'str([])'
232if str({}) != '{}': raise TestFailed, 'str({})'
Guido van Rossum85f18201992-11-27 22:53:50 +0000233
Guido van Rossume23b62f1994-11-10 22:25:26 +0000234print 'tuple'
Fred Drake132dce22000-12-12 23:11:42 +0000235if tuple(()) != (): raise TestFailed, 'tuple(())'
236if tuple((0, 1, 2, 3)) != (0, 1, 2, 3): raise TestFailed, 'tuple((0, 1, 2, 3))'
237if tuple([]) != (): raise TestFailed, 'tuple([])'
238if tuple([0, 1, 2, 3]) != (0, 1, 2, 3): raise TestFailed, 'tuple([0, 1, 2, 3])'
239if tuple('') != (): raise TestFailed, 'tuple('')'
240if tuple('spam') != ('s', 'p', 'a', 'm'): raise TestFailed, "tuple('spam')"
Guido van Rossume23b62f1994-11-10 22:25:26 +0000241
Guido van Rossum3bead091992-01-27 17:00:37 +0000242print 'type'
Fred Drake132dce22000-12-12 23:11:42 +0000243if type('') != type('123') or type('') == type(()):
Fred Drake004d5e62000-10-23 17:22:08 +0000244 raise TestFailed, 'type()'
Guido van Rossum3bead091992-01-27 17:00:37 +0000245
Guido van Rossume23b62f1994-11-10 22:25:26 +0000246print 'vars'
247a = b = None
248a = vars().keys()
249b = dir()
250a.sort()
251b.sort()
Fred Drake132dce22000-12-12 23:11:42 +0000252if a != b: raise TestFailed, 'vars()'
Guido van Rossume23b62f1994-11-10 22:25:26 +0000253import sys
254a = vars(sys).keys()
255b = dir(sys)
256a.sort()
257b.sort()
Fred Drake132dce22000-12-12 23:11:42 +0000258if a != b: raise TestFailed, 'vars(sys)'
Guido van Rossuma49d94a1995-08-11 14:24:35 +0000259def f0():
Fred Drake004d5e62000-10-23 17:22:08 +0000260 if vars() != {}: raise TestFailed, 'vars() in f0()'
Guido van Rossuma49d94a1995-08-11 14:24:35 +0000261f0()
262def f2():
Fred Drake004d5e62000-10-23 17:22:08 +0000263 f0()
264 a = 1
265 b = 2
266 if vars() != {'a': a, 'b': b}: raise TestFailed, 'vars() in f2()'
Guido van Rossuma49d94a1995-08-11 14:24:35 +0000267f2()
Guido van Rossume23b62f1994-11-10 22:25:26 +0000268
269print 'xrange'
Fred Drake132dce22000-12-12 23:11:42 +0000270if tuple(xrange(10)) != tuple(range(10)): raise TestFailed, 'xrange(10)'
271if tuple(xrange(5,10)) != tuple(range(5,10)): raise TestFailed, 'xrange(5,10)'
272if tuple(xrange(0,10,2)) != tuple(range(0,10,2)):
Fred Drake004d5e62000-10-23 17:22:08 +0000273 raise TestFailed, 'xrange(0,10,2)'
Guido van Rossume23b62f1994-11-10 22:25:26 +0000274
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000275print 'zip'
276a = (1, 2, 3)
277b = (4, 5, 6)
278t = [(1, 4), (2, 5), (3, 6)]
Fred Drake132dce22000-12-12 23:11:42 +0000279if zip(a, b) != t: raise TestFailed, 'zip(a, b) - same size, both tuples'
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000280b = [4, 5, 6]
Fred Drake132dce22000-12-12 23:11:42 +0000281if zip(a, b) != t: raise TestFailed, 'zip(a, b) - same size, tuple/list'
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000282b = (4, 5, 6, 7)
Fred Drake132dce22000-12-12 23:11:42 +0000283if zip(a, b) != t: raise TestFailed, 'zip(a, b) - b is longer'
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000284class I:
Fred Drake004d5e62000-10-23 17:22:08 +0000285 def __getitem__(self, i):
286 if i < 0 or i > 2: raise IndexError
287 return i + 4
Fred Drake132dce22000-12-12 23:11:42 +0000288if zip(a, I()) != t: raise TestFailed, 'zip(a, b) - b is instance'
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000289exc = 0
290try:
Fred Drake004d5e62000-10-23 17:22:08 +0000291 zip()
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000292except TypeError:
Fred Drake004d5e62000-10-23 17:22:08 +0000293 exc = 1
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000294except:
Fred Drake004d5e62000-10-23 17:22:08 +0000295 e = sys.exc_info()[0]
296 raise TestFailed, 'zip() - no args, expected TypeError, got %s' % e
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000297if not exc:
Fred Drake004d5e62000-10-23 17:22:08 +0000298 raise TestFailed, 'zip() - no args, missing expected TypeError'
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000299
300exc = 0
301try:
Fred Drake004d5e62000-10-23 17:22:08 +0000302 zip(None)
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000303except TypeError:
Fred Drake004d5e62000-10-23 17:22:08 +0000304 exc = 1
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000305except:
Fred Drake004d5e62000-10-23 17:22:08 +0000306 e = sys.exc_info()[0]
307 raise TestFailed, 'zip(None) - expected TypeError, got %s' % e
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000308if not exc:
Fred Drake004d5e62000-10-23 17:22:08 +0000309 raise TestFailed, 'zip(None) - missing expected TypeError'
Barry Warsaw370a29f2000-10-01 04:28:43 +0000310class G:
Fred Drake004d5e62000-10-23 17:22:08 +0000311 pass
Barry Warsaw370a29f2000-10-01 04:28:43 +0000312exc = 0
313try:
Fred Drake004d5e62000-10-23 17:22:08 +0000314 zip(a, G())
Tim Peters8572b4f2001-05-06 01:05:02 +0000315except TypeError:
Fred Drake004d5e62000-10-23 17:22:08 +0000316 exc = 1
Barry Warsaw370a29f2000-10-01 04:28:43 +0000317except:
Fred Drake004d5e62000-10-23 17:22:08 +0000318 e = sys.exc_info()[0]
319 raise TestFailed, 'zip(a, b) - b instance w/o __getitem__'
Barry Warsaw370a29f2000-10-01 04:28:43 +0000320if not exc:
Tim Peters8572b4f2001-05-06 01:05:02 +0000321 raise TestFailed, 'zip(a, b) - missing expected TypeError'
Barry Warsaw7bfc1a12000-08-03 15:48:07 +0000322
Guido van Rossum3bead091992-01-27 17:00:37 +0000323
324# Epilogue -- unlink the temp file
325
326unlink(TESTFN)