예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
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)
예제 #4
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)
예제 #5
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)
예제 #6
0
 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()))
예제 #7
0
 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)
예제 #8
0
 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)
예제 #9
0
 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()))
예제 #10
0
 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)
예제 #11
0
 def test_items(self):
     _dict = VDFDict(self.map_test)
     self.assertSequenceEqual(
         list(_dict.items()),
         self.map_test)
예제 #12
0
 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()))
예제 #13
0
 def test_items(self):
     _dict = VDFDict(self.map_test)
     self.assertSequenceEqual(list(_dict.items()), self.map_test)
예제 #14
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)
예제 #15
0
 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()))
예제 #16
0
 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)
예제 #17
0
 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()))
예제 #18
0
 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()))
예제 #19
0
 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)
예제 #20
0
 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)