def testparametrized_mutable_sequence(self): s = ParameterizedMutableSequence() s.append((4.0, 5.0)) self.obj.param1 = s self.assertEqual(len(self.obj.__parameters__), len(list(iter_parameters(self.obj)))) self.assertEqual(2, len(list(iter_values(self.obj))))
def testparametrized_mutable_set(self): s = ParameterizedMutableSet() s.add(4.0) self.obj.param1 = s self.assertEqual(len(self.obj.__parameters__) + 1, len(list(iter_parameters(self.obj)))) self.assertEqual(1, len(list(iter_values(self.obj))))
def testparametrized_mutable_mapping(self): d = ParameterizedMutableMapping() d['a'] = [1.0, 4.0, 9.0] d['b'] = 6.0 self.obj.param1 = d self.assertEqual(len(self.obj.__parameters__) + 2, len(list(iter_parameters(self.obj)))) self.assertEqual(4, len(list(iter_values(self.obj)))) self.assertEqual(3, len(expand(self.obj)))
def testiter_parameters(self): self.obj.param3 = [98, 99] subobj1 = MockParameterization('subobj1') subobj1.param1 = [88, 108] self.obj.param1 = subobj1 items = list(iter_parameters(self.obj)) self.assertEqual(len(self.obj.__parameters__) * 2, len(items)) filter_items = list(filter(lambda item: item[0] == self.obj, items)) self.assertEqual(len(self.obj.__parameters__), len(filter_items)) filter_items = list(filter(lambda item: item[0] == subobj1, items)) self.assertEqual(len(self.obj.__parameters__), len(filter_items))