Beispiel #1
0
 def test_construct_order_unimportant(self):
     td1 = assignment5.TreeDict((i, str(i)) for i in self.shuffled_list)
     td2 = assignment5.TreeDict((i, str(i)) for i in range(1, 101))
     self.assertEqual(self.treedict_get(td1, 2), "2")
     self.assertEqual(self.treedict_get(td2, 2), "2")
     self.assertTrue(
         all(
             self.treedict_get(td1, i) == self.treedict_get(td2, i)
             for i in range(110)))
Beispiel #2
0
 def test_raises_on_None_in_update_init(self):
     td = self.str_key_td()
     with self.assertRaises((ValueError, TypeError, KeyError)):
         td.update([("sss", 3), (None, 4)])
     with self.assertRaises((ValueError, TypeError, KeyError)):
         assignment5.TreeDict([("sss", 3), (None, 4)])
Beispiel #3
0
 def test_len3(self):
     td = assignment5.TreeDict()
     self.assertEqual(len(td), 0)
     td["2"] = 2
     self.assertEqual(len(td), 1)
     self.assertEqual(len(td), 1)
Beispiel #4
0
 def test_construct_td(self):
     self.call_methods(assignment5.TreeDict(self.int_key_td()), 2, "2")
     self.call_methods(assignment5.TreeDict(self.str_key_td()), "one", 1)
Beispiel #5
0
 def test_construct_dict(self):
     self.call_methods(assignment5.TreeDict({1: "1", 2: "2"}), 2, "2")
     self.call_methods(assignment5.TreeDict({"1": "1", "2": "2"}), "1", "1")
Beispiel #6
0
 def test_construct_ordered_pairs(self):
     self.call_methods(
         assignment5.TreeDict((i, str(i)) for i in range(1, 101)), 2, "2")
Beispiel #7
0
 def test_construct_unordered_pairs(self):
     self.call_methods(
         assignment5.TreeDict((i, str(i)) for i in self.shuffled_list), 1,
         "1")
Beispiel #8
0
 def test_construct_empty(self):
     td = assignment5.TreeDict()
     td["1"] = 1
     td["1"]
     td.get("1")
Beispiel #9
0
 def make_treedict(self, iterable):
     # Test two different ways of making the TreeDict each time.
     iterable = list(iterable)
     assignment5.TreeDict(iter(iterable))
     return assignment5.TreeDict(iterable)