def test_duplicate_keys(self): items = [('key1', 1), ('key1', 2), ('key3', 3), ('key1', 1)] keys = [x[0] for x in items] values = [x[1] for x in items] _dict = VDFDict(items) self.assertEqual(list(_dict.items()), items) self.assertEqual(list(_dict.keys()), keys) self.assertEqual(list(_dict.values()), values)
def test_clear(self): a = VDFDict([("1", 2), ("1", 2), ("5", 3), ("1", 2)]) a.clear() self.assertEqual(len(a), 0) self.assertEqual(len(a.keys()), 0) self.assertEqual(len(list(a.iterkeys())), 0) self.assertEqual(len(a.values()), 0) self.assertEqual(len(list(a.itervalues())), 0) self.assertEqual(len(a.items()), 0) self.assertEqual(len(list(a.iteritems())), 0)
def test_clear(self): a = VDFDict([("1",2),("1",2),("5",3),("1",2)]) a.clear() self.assertEqual(len(a), 0) self.assertEqual(len(a.keys()), 0) self.assertEqual(len(list(a.iterkeys())), 0) self.assertEqual(len(a.values()), 0) self.assertEqual(len(list(a.itervalues())), 0) self.assertEqual(len(a.items()), 0) self.assertEqual(len(list(a.iteritems())), 0)
def test_del_by_fullkey(self): a = VDFDict([("1", 1), ("1", 2), ("5", 51), ("1", 3), ("5", 52)]) b = [("1", 1), ("1", 2), ("1", 3), ("5", 52)] del a[(0, "5")] self.assertEqual(list(a.items()), b)
def test_setitem_with_duplicates(self): a = list(zip(['5'] * 5, range(50, 0, -10))) b = VDFDict() for k, v in a: b[k] = v self.assertEqual(a, list(b.items()))
def test_del(self): a = VDFDict([("1", 1), ("1", 2), ("5", 51), ("1", 3), ("5", 52)]) b = [("1", 1), ("1", 2), ("1", 3), ("5", 52)] del a["5"] self.assertEqual(list(a.items()), b)
def test_remove_all_for(self): a = VDFDict([("1", 2), ("1", 2), ("5", 3), ("1", 2)]) a.remove_all_for("1") self.assertEqual(list(a.items()), [("5", 3)]) self.assertEqual(len(a), 1)
def test_setitem(self): a = list(zip(map(str, range(5, 0, -1)), range(50, 0, -10))) b = VDFDict() for k, v in a: b[k] = v self.assertEqual(a, list(b.items()))
def test_direct_access_get(self): b = dict() a = VDFDict({"1": 2, "3": 4, "5": 6}) for k, v in a.items(): b[k] = v self.assertEqual(dict(a.items()), b)
def test_items(self): _dict = VDFDict(self.map_test) self.assertSequenceEqual( list(_dict.items()), self.map_test)
def test_update(self): a = VDFDict([("1", 2), ("1", 2), ("5", 3), ("1", 2)]) b = VDFDict() b.update([("1", 2), ("1", 2)]) b.update([("5", 3), ("1", 2)]) self.assertEqual(list(a.items()), list(b.items()))
def test_items(self): _dict = VDFDict(self.map_test) self.assertSequenceEqual(list(_dict.items()), self.map_test)
def test_del_by_fullkey(self): a = VDFDict([("1",1),("1",2),("5",51),("1",3),("5",52)]) b = [("1",1),("1",2),("1",3),("5",52)] del a[(0, "5")] self.assertEqual(list(a.items()), b)
def test_update(self): a = VDFDict([("1",2),("1",2),("5",3),("1",2)]) b = VDFDict() b.update([("1",2),("1",2)]) b.update([("5",3),("1",2)]) self.assertEqual(list(a.items()), list(b.items()))
def test_del(self): a = VDFDict([("1",1),("1",2),("5",51),("1",3),("5",52)]) b = [("1",1),("1",2),("1",3),("5",52)] del a["5"] self.assertEqual(list(a.items()), b)
def test_setitem_with_duplicates(self): a = list(zip(['5']*5, range(50, 0, -10))) b = VDFDict() for k,v in a: b[k] = v self.assertEqual(a, list(b.items()))
def test_setitem(self): a = list(zip(map(str, range(5, 0, -1)), range(50, 0, -10))) b = VDFDict() for k,v in a: b[k] = v self.assertEqual(a, list(b.items()))
def test_remove_all_for(self): a = VDFDict([("1",2),("1",2),("5",3),("1",2)]) a.remove_all_for("1") self.assertEqual(list(a.items()), [("5",3)]) self.assertEqual(len(a), 1)
def test_direct_access_get(self): b = dict() a = VDFDict({"1":2, "3":4, "5":6}) for k,v in a.items(): b[k] = v self.assertEqual(dict(a.items()), b)