summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-08-08 16:13:23 (GMT)
committerGuido van Rossum <guido@python.org>2000-08-08 16:13:23 (GMT)
commit79c9b17d174903bf42c8dd878093931d7df5cf57 (patch)
tree4f3a955297848c74639adbbd31b214b0516ce4a3 /Lib
parent164452cec416fbe032c1173d58ad89adab38820b (diff)
downloadcpython-79c9b17d174903bf42c8dd878093931d7df5cf57.zip
cpython-79c9b17d174903bf42c8dd878093931d7df5cf57.tar.gz
cpython-79c9b17d174903bf42c8dd878093931d7df5cf57.tar.bz2
Barry's patch to test the new setdefault() method.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_types.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index e22b0e2..e3a51f0 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -253,3 +253,15 @@ if d.get('c') != None: raise TestFailed, 'missing dict get, no 2nd arg'
if d.get('c', 3) != 3: raise TestFailed, 'missing dict get, w/ 2nd arg'
if d.get('a') != 1: raise TestFailed, 'present dict get, no 2nd arg'
if d.get('a', 3) != 1: raise TestFailed, 'present dict get, w/ 2nd arg'
+# dict.setdefault()
+d = {}
+if d.setdefault('key0') <> None:
+ raise TestFailed, 'missing {} setdefault, no 2nd arg'
+if d.setdefault('key0') <> None:
+ raise TestFailed, 'present {} setdefault, no 2nd arg'
+d.setdefault('key', []).append(3)
+if d['key'][0] <> 3:
+ raise TestFailed, 'missing {} setdefault, w/ 2nd arg'
+d.setdefault('key', []).append(4)
+if len(d['key']) <> 2:
+ raise TestFailed, 'present {} setdefault, w/ 2nd arg'