[Python-checkins] CVS: python/dist/src/Lib/test test_b2.py,1.15,1.16

Barry Warsaw python-dev@python.org
Thu, 3 Aug 2000 08:48:10 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory slayer.i.sourceforge.net:/tmp/cvs-serv2044

Modified Files:
	test_b2.py 
Log Message:
Added testsuite for new zip() builtin.


Index: test_b2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** test_b2.py	1999/12/23 15:36:42	1.15
--- test_b2.py	2000/08/03 15:48:07	1.16
***************
*** 256,259 ****
--- 256,295 ----
  	raise TestFailed, 'xrange(0,10,2)'
  
+ 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'
+ b = [4, 5, 6]
+ 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'
+ 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'
+ exc = 0
+ try:
+ 	zip()
+ except TypeError:
+ 	exc = 1
+ except:
+ 	e = sys.exc_info()[0]
+ 	raise TestFailed, 'zip() - no args, expected TypeError, got', e
+ if not exc:
+ 	raise TestFailed, 'zip() - no args, missing expected TypeError'
+ 
+ exc = 0
+ try:
+ 	zip(None)
+ except TypeError:
+ 	exc = 1
+ except:
+ 	e = sys.exc_info()[0]
+ 	raise TestFailed, 'zip(None) - expected TypeError, got', e
+ if not exc:
+ 	raise TestFailed, 'zip(None) - missing expected TypeError'
+ 
  
  # Epilogue -- unlink the temp file