[Python-checkins] CVS: python/dist/src/Lib/test test_types.py,1.17,1.18

Guido van Rossum python-dev@python.org
Tue, 12 Dec 2000 14:03:03 -0800


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

Modified Files:
	test_types.py 
Log Message:
Added test for {}.popitem().


Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** test_types.py	2000/11/30 19:30:21	1.17
--- test_types.py	2000/12/12 22:02:59	1.18
***************
*** 266,267 ****
--- 266,291 ----
  if len(d['key']) <> 2:
      raise TestFailed, 'present {} setdefault, w/ 2nd arg'
+ # dict.popitem()
+ for copymode in -1, +1:
+     # -1: b has same structure as a
+     # +1: b is a.copy()
+     for log2size in range(12):
+         size = 2**log2size
+         a = {}
+         b = {}
+         for i in range(size):
+             a[`i`] = i
+             if copymode < 0:
+                 b[`i`] = i
+         if copymode > 0:
+             b = a.copy()
+         for i in range(size):
+             ka, va = ta = a.popitem()
+             if va != int(ka): raise TestFailed, "a.popitem: %s" % str(ta)
+             kb, vb = tb = b.popitem()
+             if vb != int(kb): raise TestFailed, "b.popitem: %s" % str(tb)
+             if copymode < 0 and ta != tb:
+                 raise TestFailed, "a.popitem != b.popitem: %s, %s" % (
+                     str(ta), str(tb))
+         if a: raise TestFailed, 'a not empty after popitems: %s' % str(a)
+         if b: raise TestFailed, 'b not empty after popitems: %s' % str(b)