diff options
author | Guido van Rossum <guido@python.org> | 2001-04-20 16:50:40 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-04-20 16:50:40 (GMT) |
commit | 0dbb4fba4c59741466ac18eeb946ca56989717d4 (patch) | |
tree | c7c0fe7c20813024cb023075b597fee3c99abd64 /Lib | |
parent | 78fe5308b427298a2bb3c80c1d0f6117d18fcf62 (diff) | |
download | cpython-0dbb4fba4c59741466ac18eeb946ca56989717d4.zip cpython-0dbb4fba4c59741466ac18eeb946ca56989717d4.tar.gz cpython-0dbb4fba4c59741466ac18eeb946ca56989717d4.tar.bz2 |
Implement, test and document "key in dict" and "key not in dict".
I know some people don't like this -- if it's really controversial,
I'll take it out again. (If it's only Alex Martelli who doesn't like
it, that doesn't count as "real controversial" though. :-)
That's why this is a separate checkin from the iterators stuff I'm
about to check in next.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_types.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index bf35687..9df3955 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -221,6 +221,8 @@ print '6.6 Mappings == Dictionaries' d = {} if d.keys() != []: raise TestFailed, '{}.keys()' if d.has_key('a') != 0: raise TestFailed, '{}.has_key(\'a\')' +if ('a' in d) != 0: raise TestFailed, "'a' in {}" +if ('a' not in d) != 1: raise TestFailed, "'a' not in {}" if len(d) != 0: raise TestFailed, 'len({})' d = {'a': 1, 'b': 2} if len(d) != 2: raise TestFailed, 'len(dict)' @@ -229,6 +231,8 @@ k.sort() if k != ['a', 'b']: raise TestFailed, 'dict keys()' if d.has_key('a') and d.has_key('b') and not d.has_key('c'): pass else: raise TestFailed, 'dict keys()' +if 'a' in d and 'b' in d and 'c' not in d: pass +else: raise TestFailed, 'dict keys() # in/not in version' if d['a'] != 1 or d['b'] != 2: raise TestFailed, 'dict item' d['c'] = 3 d['a'] = 4 |