[pypy-commit] pypy default: Add a test for 'OrderedDict.popitem(last=False)'
arigo
noreply at buildbot.pypy.org
Tue Dec 16 17:10:41 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r74954:702aaf7c9043
Date: 2014-12-16 16:10 +0000
http://bitbucket.org/pypy/pypy/changeset/702aaf7c9043/
Log: Add a test for 'OrderedDict.popitem(last=False)'
diff --git a/lib-python/2.7/test/test_collections.py b/lib-python/2.7/test/test_collections.py
--- a/lib-python/2.7/test/test_collections.py
+++ b/lib-python/2.7/test/test_collections.py
@@ -1108,6 +1108,16 @@
od.popitem()
self.assertEqual(len(od), 0)
+ def test_popitem_first(self):
+ pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
+ shuffle(pairs)
+ od = OrderedDict(pairs)
+ while pairs:
+ self.assertEqual(od.popitem(last=False), pairs.pop(0))
+ with self.assertRaises(KeyError):
+ od.popitem(last=False)
+ self.assertEqual(len(od), 0)
+
def test_pop(self):
pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
shuffle(pairs)
More information about the pypy-commit
mailing list