Mailing List Archive

python/dist/src/Lib/test test_types.py,1.26,1.27
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv15040/Lib/test

Modified Files:
test_types.py
Log Message:
Add Raymond Hettinger's d.pop(). See SF patch 539949.


Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** test_types.py 24 Mar 2002 01:24:07 -0000 1.26
--- test_types.py 12 Apr 2002 15:11:59 -0000 1.27
***************
*** 477,480 ****
--- 477,495 ----
else: raise TestFailed, "{}.popitem doesn't raise KeyError"

+ # Tests for pop with specified key
+ d.clear()
+ k, v = 'abc', 'def'
+ d[k] = v
+ try: d.pop('ghi')
+ except KeyError: pass
+ else: raise TestFailed, "{}.pop(k) doesn't raise KeyError when k not in dictionary"
+
+ if d.pop(k) != v: raise TestFailed, "{}.pop(k) doesn't find known key/value pair"
+ if len(d) > 0: raise TestFailed, "{}.pop(k) failed to remove the specified pair"
+
+ try: d.pop(k)
+ except KeyError: pass
+ else: raise TestFailed, "{}.pop(k) doesn't raise KeyError when dictionary is empty"
+
d[1] = 1
try: