def test_can_set_lists_with_simple_items(self): target = Data() target.A = [1, 2] self.assertIsInstance(target.A, list) self.assertEqual(target.A, [1, 2])
def test_can_set_simple_attributes(self): target = Data() target.A = 1 target.B = 'foo' self.assertEqual(target.DATA, {'A': 1, 'B': 'foo'})
def test_can_set_dict_attributes(self): target = Data() target.A = {'x': 1} self.assertIsInstance(target.A, Data) self.assertEqual(target.A.DATA, {'x': 1}) self.assertEqual(target.DATA, {'A': {'x': 1}})
def test_can_set_lists_with_nested_dicts(self): target = Data() target.A = [[{'x': 1}], [{'y': 2}]] self.assertIsInstance(target.A, list) self.assertIsInstance(target.A[0][0], Data) self.assertIsInstance(target.A[1][0], Data)