Esempio n. 1
0
 def test_mod(self):
     other_dict = smart({'t1': 1, 'ta': 2, 't32': 3, 'j3': 4})
     result1 = other_dict % '^t[0-9]+$'
     result2 = other_dict % compile('^t[0-9]+$')
     
     self.assertDictEqual(smart(result1), {'t1': 1, 't32': 3})
     self.assertDictEqual(smart(result2), {'t1': 1, 't32': 3})
Esempio n. 2
0
 def test_del_slice(self):
     copy_list = deepcopy(self.smart_list)
     del copy_list[0:10]
     result_list = smart(copy_list)
     compare_list = list(range(11, 21))
     
     self.assertListEqual(result_list, compare_list)
Esempio n. 3
0
 def test_multiple_remove(self):
     normal_list = copy(self.test_list)
     result = self.smart_list - [18, 19, 20]
     
     for i in [18, 19, 20]:
         normal_list.remove(i)
 
     self.assertListEqual(smart(result), normal_list)
Esempio n. 4
0
 def test_step(self):
     self.assertListEqual(smart(self.smart_list[::5]), [1, 6, 11, 16])
Esempio n. 5
0
 def test_del_item(self):
     copy_list = deepcopy(self.smart_list)
     del copy_list[4]
     result_list = smart(copy_list)
     
     self.assertFalse(5 in result_list)
Esempio n. 6
0
 def test_add(self):
     result = self.smart_dict + {'d': 4}
     
     self.assertDictEqual(smart(result), {'a': 1, 'b': 2, 'c': 3, 'd': 4})
Esempio n. 7
0
    def test_intersection(self):
        result = self.smart_list & [1, 2, 3, 99]

        self.assertListEqual(smart(result), [1, 2, 3])
Esempio n. 8
0
 def test_single_remove(self):
     normal_list = copy(self.test_list)
     result = self.smart_list - 20
     normal_list.remove(20)
 
     self.assertListEqual(smart(result), normal_list)
Esempio n. 9
0
 def test_concat(self):
     result = self.smart_list + [21, 22, 23]
 
     self.assertListEqual(smart(result), self.test_list + [21, 22, 23])
Esempio n. 10
0
 def test_append(self):
     example_list = smart([1, 2, 3])
     example_list.append(4)
     
     self.assertEqual(example_list[3], 4)
Esempio n. 11
0
 def test_flatten(self):
     example_list = smart([1, [2, 3, [4]], [5, 6], 7, [8, [[9, [[10]]]]]])
     comparison_list = list(range(1, 11))
     result = smart(~example_list)
     
     self.assertListEqual(result, comparison_list)
Esempio n. 12
0
 def test_convert_normal(self):
     self.assertDictEqual(smart(self.smart_dict), self.test_dict)
Esempio n. 13
0
 def setUp(self):
     self.test_dict = {'a': 1, 'b': 2, 'c': 3}
     self.smart_dict = smart(self.test_dict)
Esempio n. 14
0
 def test_copy(self):
     copy_dict = self.smart_dict.copy()
     
     self.assertDictEqual(smart(self.smart_dict), smart(copy_dict))
Esempio n. 15
0
 def test_flatten(self):
     other_dict = smart({'a': 1, 'b': {'c': 2}})
     flattened = ~other_dict
 
     self.assertDictEqual(smart(flattened), {'a': 1, 'b-c': 2})
Esempio n. 16
0
 def test_mul(self):
     result = self.smart_list * 2
     
     self.assertListEqual(smart(result), self.test_list * 2)
Esempio n. 17
0
 def setUp(self):
     self.test_list = list(range(1, 21))
     self.smart_list = smart(self.test_list)
Esempio n. 18
0
 def test_get_slice(self):
     self.assertListEqual(smart(self.smart_list[1:4]), [2, 3, 4])
Esempio n. 19
0
 def test_add_item(self):
     normal_list = copy(self.test_list)
     result = self.smart_list + 21
     normal_list.append(21)
 
     self.assertListEqual(smart(result), normal_list)
Esempio n. 20
0
 def test_copy(self):
     copy_list = self.smart_list.copy()
     
     self.assertListEqual(smart(self.smart_list), smart(copy_list))
Esempio n. 21
0
 def test_convert_normal(self):
     self.assertListEqual(smart(self.smart_list), self.test_list)
Esempio n. 22
0
 def test_get_multiple(self):
     result = self.smart_list[[2, 4, -1]]
     list_result = smart(result)
     
     self.assertListEqual(list_result, [3, 5, 20])
Esempio n. 23
0
 def test_filter(self):
     normal_list = copy(self.test_list)
     result = self.smart_list % (lambda x: not x % 2)
     normal_result = list(filter(lambda x: not x % 2, normal_list))
     
     self.assertListEqual(smart(result), normal_result)
Esempio n. 24
0
 def test_get_multiple(self):
     filtered_dict = self.smart_dict[['a', 'b']]
     
     self.assertDictEqual(smart(filtered_dict), {'a': 1, 'b': 2})