Пример #1
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[1] = "one"
     s[2] = "two"
     s[3] = "three"
     s[4] = "four"
     s[5] = "five"
     self.assertEqual(s.__keys__(), [1, 2, 3, 4, 5])
Пример #2
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     for i in range(21):
         s[i] = str(i)
     self.assertEqual(s.__values__(), [
         '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12',
         '13', '14', '15', '16', '17', '18', '19', '20'
     ])
Пример #3
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[1] = "one"
     s[2] = "two"
     s[3] = "three"
     s[4] = "four"
     s[5] = "five"
     self.assertRaises(RuntimeError, lambda: s.__delitem__(6))
Пример #4
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[1] = "one"
     s[2] = "two"
     s[3] = "three"
     s[4] = "four"
     s[5] = "five"
     self.assertEqual(s.__values__(),
                      ['one', 'two', 'three', 'four', 'five'])
Пример #5
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     for i in range(41):
         s[i] = str(i)
     self.assertEqual(s.__keys__(), [
         0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
         19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
         36, 37, 38, 39, 40
     ])
Пример #6
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[1] = "one"
     s[2] = "two"
     s[3] = "three"
     s[4] = "four"
     s[5] = "five"
     self.assertEqual(s.__items__(), [(1, 'one'), (2, 'two'), (3, 'three'),
                                      (4, 'four'), (5, 'five')])
Пример #7
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[1] = "one"
     s[2] = "two"
     s[3] = "three"
     s[4] = "four"
     r = Dictionary()
     r[1] = "one"
     r[2] = "two"
     r[3] = "three"
     r[4] = "four"
     r[5] = "five"
     self.assertFalse(s.__eq__(r))
Пример #8
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[1] = "one"
     s[1] = "one"
     self.assertEqual(len(s), 1)
     self.assertEqual(s[1], "one")
Пример #9
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     for i in range(41):
         s[i] = str(i)
     self.assertEqual(s.__items__(),
                      [(0, '0'), (1, '1'), (2, '2'), (3, '3'), (4, '4'),
                       (5, '5'), (6, '6'), (7, '7'), (8, '8'), (9, '9'),
                       (10, '10'), (11, '11'), (12, '12'), (13, '13'),
                       (14, '14'), (15, '15'), (16, '16'), (17, '17'),
                       (18, '18'), (19, '19'), (20, '20'), (21, '21'),
                       (22, '22'), (23, '23'), (24, '24'), (25, '25'),
                       (26, '26'), (27, '27'), (28, '28'), (29, '29'),
                       (30, '30'), (31, '31'), (32, '32'), (33, '33'),
                       (34, '34'), (35, '35'), (36, '36'), (37, '37'),
                       (38, '38'), (39, '39'), (40, '40')])
Пример #10
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[0] = "zero"
     s[10] = "ten"
     self.assertEqual(len(s), 2)
     self.assertTrue(0 in s)
     self.assertTrue(10 in s)
Пример #11
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     for i in range(11):
         s[i] = str(i)
     self.assertEqual(len(s), 11)
     self.assertEqual(
         str(s),
         "[[0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], "
         "[6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10']]")
Пример #12
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     for i in range(41):
         s[i] = str(i)
     self.assertEqual(len(s), 41)
     self.assertEqual(
         str(s),
         "[[0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], "
         "[6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10'], [11, '11'], "
         "[12, '12'], [13, '13'], [14, '14'], [15, '15'], [16, '16'], "
         "[17, '17'], [18, '18'], [19, '19'], [20, '20'], [21, '21'], "
         "[22, '22'], [23, '23'], [24, '24'], [25, '25'], [26, '26'], "
         "[27, '27'], [28, '28'], [29, '29'], [30, '30'], [31, '31'], "
         "[32, '32'], [33, '33'], [34, '34'], [35, '35'], [36, '36'], "
         "[37, '37'], [38, '38'], [39, '39'], [40, '40']]")
     for i in range(20):
         s.__delitem__(i)
     self.assertEqual(
         str(s),
         "[[20, '20'], [21, '21'], [22, '22'], [23, '23'], [24, '24'], "
         "[25, '25'], [26, '26'], [27, '27'], [28, '28'], [29, '29'], "
         "[30, '30'], [31, '31'], [32, '32'], [33, '33'], [34, '34'], "
         "[35, '35'], [36, '36'], [37, '37'], [38, '38'], [39, '39'], "
         "[40, '40']]")
     for i in range(20, 34):
         s.__delitem__(i)
     self.assertEqual(
         str(s),
         "[[40, '40'], [34, '34'], [35, '35'], [36, '36'], [37, '37'], "
         "[38, '38'], [39, '39']]")
Пример #13
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[False] = 1
     self.assertTrue(False in s)
     self.assertEqual(s[False], 1)
Пример #14
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[1] = None
     self.assertTrue(1 in s)
     self.assertEqual(s[1], None)
Пример #15
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     for i in range(11):
         s[i] = str(i)
     self.assertEqual(len(s), 11)
     self.assertEqual(
         str(s),
         "[[0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], "
         "[6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10']]")
     s.__delitem__(1)
     s.__delitem__(5)
     s.__delitem__(2)
     s.__delitem__(3)
     s.__delitem__(4)
     s.__delitem__(0)
     s.__delitem__(6)
     s.__delitem__(7)
     s.__delitem__(8)
     self.assertEqual(len(s), 2)
     self.assertEqual(str(s), "[[10, '10'], [9, '9']]")
Пример #16
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     self.assertEqual(s.__items__(), [])
Пример #17
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     r = Dictionary()
     r[1] = "one"
     self.assertFalse(s.__eq__(r))
Пример #18
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     r = Dictionary()
     self.assertTrue(s.__eq__(r))
Пример #19
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[1] = False
     self.assertTrue(1 in s)
     self.assertFalse(s[1])
Пример #20
0
 def test(self):
     """Dictionary test method"""
     s = Dictionary()
     s[1] = "one"
     s[2] = "two"
     s[3] = "three"
     s[4] = "four"
     s[5] = "five"
     self.assertEqual(len(s), 5)
     s.__delitem__(1)
     s.__delitem__(5)
     s.__delitem__(2)
     s.__delitem__(3)
     s.__delitem__(4)
     self.assertEqual(len(s), 0)
     s[False] = 1
     s[1] = None
     s.__delitem__(False)
     s.__delitem__(1)
     self.assertEqual(len(s), 0)