Exemplo n.º 1
0
    def test_component_no_overwrite_parent(self):
        """Values in parent configuration are not overwritten."""
        parent_config = Configuration(self.sitename)
        parent_config.set('compa', 'opt1', 3)
        parent_config.save()
        config = self._read()
        config.set('inherit', 'file', 'trac-site.ini')
        config.save()
        config.parse_if_needed(True)
        config.set_defaults(component='trac.tests.config.CompA')
        config.save()

        expected = [
            '# -*- coding: utf-8 -*-\n',
            '\n',
            '[compa]\n',
            'opt1 = 3\n',
            '\n',
        ]
        self.assertEqual(expected, readlines(self.sitename))

        expected = [
            '# -*- coding: utf-8 -*-\n',
            '\n',
            '[compa]\n',
            'opt2 = a\n',
            '\n',
            '[inherit]\n',
            'file = trac-site.ini\n',
            '\n',
        ]
        self.assertEqual(expected, readlines(self.filename))
Exemplo n.º 2
0
    def test_component_no_overwrite_parent(self):
        """Values in parent configuration are not overwritten."""
        parent_config = Configuration(self.sitename)
        parent_config.set('compa', 'opt1', 3)
        parent_config.save()
        config = self._read()
        config.set('inherit', 'file', 'trac-site.ini')
        config.save()
        config.parse_if_needed(True)
        config.set_defaults(component='trac.tests.config.CompA')
        config.save()

        with open(self.sitename, 'r') as f:
            self.assertEqual('# -*- coding: utf-8 -*-\n', f.next())
            self.assertEqual('\n',                        f.next())
            self.assertEqual('[compa]\n',                 f.next())
            self.assertEqual('opt1 = 3\n',                f.next())
            self.assertEqual('\n',                        f.next())
            self.assertRaises(StopIteration, f.next)

        with open(self.filename, 'r') as f:
            self.assertEqual('# -*- coding: utf-8 -*-\n', f.next())
            self.assertEqual('\n',                        f.next())
            self.assertEqual('[compa]\n',                 f.next())
            self.assertEqual('opt2 = a\n',                f.next())
            self.assertEqual('\n',                        f.next())
            self.assertEqual('[inherit]\n',               f.next())
            self.assertEqual('file = trac-site.ini\n',    f.next())
            self.assertEqual('\n',                        f.next())
            self.assertRaises(StopIteration, f.next)
Exemplo n.º 3
0
    def test_component_no_overwrite_parent(self):
        """Values in parent configuration are not overwritten."""
        parent_config = Configuration(self.sitename)
        parent_config.set('compa', 'opt1', 3)
        parent_config.save()
        config = self._read()
        config.set('inherit', 'file', 'trac-site.ini')
        config.save()
        config.parse_if_needed(True)
        config.set_defaults(component='trac.tests.config.CompA')
        config.save()

        with open(self.sitename, 'r') as f:
            self.assertEqual('# -*- coding: utf-8 -*-\n', f.next())
            self.assertEqual('\n', f.next())
            self.assertEqual('[compa]\n', f.next())
            self.assertEqual('opt1 = 3\n', f.next())
            self.assertEqual('\n', f.next())
            self.assertRaises(StopIteration, f.next)

        with open(self.filename, 'r') as f:
            self.assertEqual('# -*- coding: utf-8 -*-\n', f.next())
            self.assertEqual('\n', f.next())
            self.assertEqual('[compa]\n', f.next())
            self.assertEqual('opt2 = a\n', f.next())
            self.assertEqual('\n', f.next())
            self.assertEqual('[inherit]\n', f.next())
            self.assertEqual('file = trac-site.ini\n', f.next())
            self.assertEqual('\n', f.next())
            self.assertRaises(StopIteration, f.next)