Rev 137: Implement .items() since we use it in a place where we mutate the dict. in http://bazaar.launchpad.net/~jameinel/meliae/mem-object-collection
John Arbash Meinel
john at arbash-meinel.com
Mon Dec 28 05:15:21 GMT 2009
At http://bazaar.launchpad.net/~jameinel/meliae/mem-object-collection
------------------------------------------------------------
revno: 137
revision-id: john at arbash-meinel.com-20091228051505-rrc9gc603b7ijhpy
parent: john at arbash-meinel.com-20091228051325-w62x918u0rrz5v2d
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: mem-object-collection
timestamp: Sun 2009-12-27 23:15:05 -0600
message:
Implement .items() since we use it in a place where we mutate the dict.
-------------- next part --------------
=== modified file 'meliae/_loader.pyx'
--- a/meliae/_loader.pyx 2009-12-28 05:13:25 +0000
+++ b/meliae/_loader.pyx 2009-12-28 05:15:05 +0000
@@ -591,6 +591,9 @@
values.append(address)
return iter(values)
+ def items(self):
+ return self.iteritems()
+
def iteritems(self):
"""Iterate over (key, value) tuples."""
cdef long i
=== modified file 'meliae/tests/test__loader.py'
--- a/meliae/tests/test__loader.py 2009-12-28 05:13:25 +0000
+++ b/meliae/tests/test__loader.py 2009-12-28 05:15:05 +0000
@@ -230,6 +230,19 @@
del moc[0]
self.assertEqual([1024, 512], [x.address for x in moc.itervalues()])
+ def test_items(self):
+ moc = _loader.MemObjectCollection()
+ moc.add(0, 'bar', 100)
+ moc.add(1024, 'baz', 102)
+ moc.add(512, 'bing', 103)
+ items = moc.items()
+ self.assertTrue(isinstance(items, list))
+ self.assertEqual([(0, 0), (1024, 1024), (512, 512)],
+ [(k, v.address) for k,v in items])
+ del moc[0]
+ self.assertEqual([(1024, 1024), (512, 512)],
+ [(k, v.address) for k,v in moc.items()])
+
def test_iteritems(self):
moc = _loader.MemObjectCollection()
moc.add(0, 'bar', 100)
More information about the bazaar-commits
mailing list