diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-04-21 09:13:15 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-04-21 09:13:15 (GMT) |
commit | a3f98d6bac3fbfc0e010360b11793bbd8a8f4c85 (patch) | |
tree | 5486edd566e74a59ec25420ad07e79d92b0349d7 /Lib/test/test_userdict.py | |
parent | e99b97e58a274eb61d7346e786ad242e5253d3db (diff) | |
download | cpython-a3f98d6bac3fbfc0e010360b11793bbd8a8f4c85.zip cpython-a3f98d6bac3fbfc0e010360b11793bbd8a8f4c85.tar.gz cpython-a3f98d6bac3fbfc0e010360b11793bbd8a8f4c85.tar.bz2 |
Give UserDict new __contains__ and __iter__ methods.
Diffstat (limited to 'Lib/test/test_userdict.py')
-rw-r--r-- | Lib/test/test_userdict.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py index 08b7a13..9aa01d0 100644 --- a/Lib/test/test_userdict.py +++ b/Lib/test/test_userdict.py @@ -81,12 +81,15 @@ verify(u2.keys() == d2.keys()) verify(u2.items() == d2.items()) verify(u2.values() == d2.values()) -# Test has_key +# Test has_key and "in". for i in u2.keys(): verify(u2.has_key(i) == 1) + verify((i in u2) == 1) verify(u1.has_key(i) == d1.has_key(i)) + verify((i in u1) == (i in d1)) verify(u0.has_key(i) == d0.has_key(i)) + verify((i in u0) == (i in d0)) # Test update @@ -100,3 +103,14 @@ for i in u2.keys(): verify(u2.get(i) == u2[i]) verify(u1.get(i) == d1.get(i)) verify(u0.get(i) == d0.get(i)) + +# Test "in" iteration. +for i in xrange(20): + u2[i] = str(i) +ikeys = [] +for k in u2: + ikeys.append(k) +ikeys.sort() +keys = u2.keys() +keys.sort() +verify(ikeys == keys) |