コード例 #1
0
 def test_enumeration(self):
     """Test mapping enumeration: keys(), values(), items()"""
     collection = BaseCollection(ITEMS, NAMES)
     assert set(collection.keys()) == set(ITEMS.keys())  # sufficient
     # all keys present
     for uid in collection.keys():
         assert uid in collection
         item = ITEMS.get(uid)
         assert ITEMS.get(uid) in collection.values()
         assert (uid, item) in collection.items()
コード例 #2
0
 def test_iteration(self):
     collection = BaseCollection(ITEMS, NAMES)
     assert set(collection.keys()) == set(ITEMS.keys())  # sufficient
     assert set(collection.iterkeys()) == set(collection.keys())
     assert set(collection.itervalues()) == set(collection.values())
     assert set(collection.iteritems()) == set(collection.items())
     # all keys present
     for uid in collection.iterkeys():
         assert uid in collection
         item = ITEMS.get(uid)
         assert ITEMS.get(uid) in collection.itervalues()
         assert (uid, item) in collection.iteritems()