From 1d6c4c702bd8b5576d17217140d3eaf7c6d7ef29 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Tue, 18 Feb 2014 22:55:45 +0100 Subject: config: Deprecate legacy config sections We deprecate sections starting with git- and gbp- to reduce the confusion about what gets parsed first. --- tests/18_test_Config.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'tests/18_test_Config.py') diff --git a/tests/18_test_Config.py b/tests/18_test_Config.py index f7ba8c9..1560ece 100644 --- a/tests/18_test_Config.py +++ b/tests/18_test_Config.py @@ -1,20 +1,27 @@ # vim: set fileencoding=utf-8 : import os +import sys import unittest from gbp.config import GbpOptionParser, GbpOptionGroup -from . import context +from . testutils import GbpLogTester + +class TestConfigParser(unittest.TestCase, GbpLogTester): + def __init__(self, methodName='runTest'): + unittest.TestCase.__init__(self, methodName) + GbpLogTester.__init__(self) -class TestConfigParser(unittest.TestCase): def setUp(self): self.conffiles_save = os.environ.get('GBP_CONF_FILES') self.confname = 'tests/data/test1.conf' self.assertTrue(os.stat(self.confname)) os.environ['GBP_CONF_FILES'] = self.confname + self._capture_log(True) def tearDown(self): if self.conffiles_save: os.environ['GBP_CONF_FILES'] = self.conffiles_save + self._capture_log(False) def test_default(self): """ @@ -32,6 +39,8 @@ class TestConfigParser(unittest.TestCase): for prefix in [ '', 'git-', 'gbp-' ]: parser = GbpOptionParser('%scmd1' % prefix) self.assertEqual(parser.config['single_override_option1'], 'single_override_value1') + # No deprecation warning since we test1.conf section is [cmd1] + self.assertEqual(self._get_log(), []) def test_single_git_override(self): """ @@ -40,6 +49,8 @@ class TestConfigParser(unittest.TestCase): for prefix in [ '', 'git-' ]: parser = GbpOptionParser('%scmd2' % prefix) self.assertEqual(parser.config['single_git_override_option1'], 'single_git_override_value1') + for line in range(0,2): + self._check_log(line, ".*Old style config section \[git-cmd2\] found please rename to \[cmd2\]") def test_single_gbp_override(self): """ @@ -48,7 +59,9 @@ class TestConfigParser(unittest.TestCase): for prefix in [ '', 'gbp-' ]: parser = GbpOptionParser('%scmd3' % prefix) self.assertEqual(parser.config['single_gbp_override_option1'], 'single_gbp_override_value1') - # FIXME: for all prefixes + for line in range(0,2): + self._check_log(line, ".*Old style config section \[gbp-cmd3\] found please rename to \[cmd3\]") + def test_new_overrides_git(self): """ @@ -65,7 +78,7 @@ class TestConfigParser(unittest.TestCase): def test_get_config_file_value(self): """ - Read a single value from the parse config + Read a single value from the parsed config """ parser = GbpOptionParser('cmd4') self.assertEqual(parser.get_config_file_value('new_overrides_git_option1'), -- cgit v1.2.3