From: Barry Warsaw Date: Mon, 20 Oct 1997 17:34:43 +0000 (+0000) Subject: Added tests of dict.get() X-Git-Tag: v1.5b1~192 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b887c791154a653dadbfabff4978179698c23eb;p=python Added tests of dict.get() --- diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index eedf65aead..c3d59cb941 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -189,3 +189,9 @@ d.update({1:1, 2:2, 3:3}) if d != {1:1, 2:2, 3:3}: raise TestFailed, 'dict update' if d.copy() != {1:1, 2:2, 3:3}: raise TestFailed, 'dict copy' if {}.copy() != {}: raise TestFailed, 'empty dict copy' +# dict.get() +d = {'a' : 1, 'b' : 2} +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'