コード例 #1
0
    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])
コード例 #2
0
    def test_can_set_simple_attributes(self):

        target = Data()

        target.A = 1
        target.B = 'foo'

        self.assertEqual(target.DATA, {'A': 1, 'B': 'foo'})
コード例 #3
0
    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}})
コード例 #4
0
    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)