Exemplo n.º 1
0
    def test_load(self):
        """ test feature load """

        yamldata = '''
                    key1: 'value1'
                    key2:
                       - 'item1'
                       - 'item2'
                    key3:
                       key31: 'value31'
                       key32: 'value32'
                    '''

        config = ymlconfig.load(yamldata)
        self.assertEqual(config.key1, 'value1')
        self.assertEqual(config.key2[1], 'item2')
        self.assertEqual(config.key3.key31, 'value31')
Exemplo n.º 2
0
    def test_load(self):
        """ test feature load """

        yamldata = '''
                    key1: 'value1'
                    key2:
                       - 'item1'
                       - 'item2'
                    key3:
                       key31: 'value31'
                       key32: 'value32'
                    '''

        config = ymlconfig.load(yamldata)
        self.assertEqual(config.key1, 'value1')
        self.assertEqual(config.key2[1], 'item2')
        self.assertEqual(config.key3.key31, 'value31')
Exemplo n.º 3
0
    def test_python_format(self):
        """ test feature test_python_format """

        yamldata = '''
                    key1: &alias1 'value1'
                    key2:
                       - 'item1'
                       - 'item2'
                    key3: !format
                        format: '{arg1} {arg2}'
                        arg1: *alias1
                        arg2: 'arg2'

                    '''

        config = ymlconfig.load(yamldata)
        self.assertEqual(config.key1, 'value1')
        self.assertEqual(config.key3, 'value1 arg2')
Exemplo n.º 4
0
    def test_format_substitution(self):
        """ test feature test_format with substitution of kwargs"""

        yamldata = '''
                    key1: 'value1'
                    key2:
                        - 'item1'
                        - 'item2'
                    key3: !format
                        format: 'kw1: {kwarg1} kw2: {kwarg2}'
                        kwarg1: 'default1'
                        kwarg2: 'default2'

                    '''

        config = ymlconfig.load(yamldata, kwarg2='fromkw2')
        self.assertEqual(config.key1, 'value1')
        self.assertEqual(config.key3, 'kw1: default1 kw2: fromkw2')
Exemplo n.º 5
0
    def test_python_format(self):
        """ test feature test_python_format """

        yamldata = '''
                    key1: &alias1 'value1'
                    key2:
                       - 'item1'
                       - 'item2'
                    key3: !format
                        format: '{arg1} {arg2}'
                        arg1: *alias1
                        arg2: 'arg2'

                    '''

        config = ymlconfig.load(yamldata)
        self.assertEqual(config.key1, 'value1')
        self.assertEqual(config.key3, 'value1 arg2')
Exemplo n.º 6
0
    def test_format_substitution(self):
        """ test feature test_format with substitution of kwargs"""

        yamldata = '''
                    key1: 'value1'
                    key2:
                        - 'item1'
                        - 'item2'
                    key3: !format
                        format: 'kw1: {kwarg1} kw2: {kwarg2}'
                        kwarg1: 'default1'
                        kwarg2: 'default2'

                    '''

        config = ymlconfig.load(yamldata, kwarg2='fromkw2')
        self.assertEqual(config.key1, 'value1')
        self.assertEqual(config.key3, 'kw1: default1 kw2: fromkw2')