[Python-checkins] python/dist/src/Lib/test test_types.py,1.46,1.47 test_userdict.py,1.12,1.13
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Thu, 06 Mar 2003 15:54:30 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv11840/Lib/test
Modified Files:
test_types.py test_userdict.py
Log Message:
SF patch #693753: fix for bug 639806: default for dict.pop
(contributed by Michael Stone.)
Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** test_types.py 23 Feb 2003 23:11:41 -0000 1.46
--- test_types.py 6 Mar 2003 23:54:27 -0000 1.47
***************
*** 644,650 ****
x = 4503599627370496L
y = 4503599627370496
! h = {x: 'anything', y: 'something else'}
if h[x] != h[y]:
raise TestFailed, "long/int key should match"
d[1] = 1
--- 644,654 ----
x = 4503599627370496L
y = 4503599627370496
! h = {x: 'anything', y: 'something else'}
if h[x] != h[y]:
raise TestFailed, "long/int key should match"
+
+ if d.pop(k, v) != v: raise TestFailed, "{}.pop(k, v) doesn't return default value"
+ d[k] = v
+ if d.pop(k, 1) != v: raise TestFailed, "{}.pop(k, v) doesn't find known key/value pair"
d[1] = 1
Index: test_userdict.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userdict.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** test_userdict.py 19 Jan 2003 23:26:59 -0000 1.12
--- test_userdict.py 6 Mar 2003 23:54:27 -0000 1.13
***************
*** 140,143 ****
--- 140,146 ----
self.assertEqual(t.pop("x"), 42)
self.assertRaises(KeyError, t.pop, "x")
+ self.assertEqual(t.pop("x", 1), 1)
+ t["x"] = 42
+ self.assertEqual(t.pop("x", 1), 42)
# Test popitem
***************
*** 243,246 ****
--- 246,252 ----
self.assert_(10 not in s)
s[10] = 'ten'
+ self.assertEqual(s.pop("x", 1), 1)
+ s["x"] = 42
+ self.assertEqual(s.pop("x", 1), 42)
# popitem