summaryrefslogtreecommitdiffstats
path: root/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2014-10-22 11:03:48 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2014-11-10 17:35:43 -0600
commit4ec92cb9e7d1eb2f90d36e5255ee8814ca0a8513 (patch)
treef375d640c4f4e004600a1c3f7316a7d167e2f328 /testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
parent72201ddac165e45da09521b77660b2e155ca36cd (diff)
downloadbcfg2-4ec92cb9e7d1eb2f90d36e5255ee8814ca0a8513.tar.gz
bcfg2-4ec92cb9e7d1eb2f90d36e5255ee8814ca0a8513.tar.bz2
bcfg2-4ec92cb9e7d1eb2f90d36e5255ee8814ca0a8513.zip
Options: ensure <repository> macros are always fixed up
This fixes several cases in which <repository> macros would not be properly processed: options that are not added to the parser yet when early options are parsed; and config file options whose default value is used.
Diffstat (limited to 'testsuite/Testsrc/Testlib/TestOptions/TestOptions.py')
-rw-r--r--testsuite/Testsrc/Testlib/TestOptions/TestOptions.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
index b76cd6d3a..9f4a7873c 100644
--- a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
+++ b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
@@ -20,6 +20,7 @@ class TestBasicOptions(OptionTestCase):
# that's probably bad -- and it's definitely bad if we ever
# want to do real on-the-fly config changes -- but it's easier
# to leave it as is and set the options on each test.
+ OptionTestCase.setUp(self)
self.options = [
BooleanOption("--test-true-boolean", env="TEST_TRUE_BOOLEAN",
cf=("test", "true_boolean"), default=True),
@@ -367,13 +368,16 @@ class TestBasicOptions(OptionTestCase):
parser.add_options,
[Option(cf=("test", "option"))])
- @make_config()
+ @make_config({"test": {"test_path": "<repository>/test"}})
def test_repository_macro(self, config_file):
"""fix up <repository> macros."""
result = argparse.Namespace()
parser = Parser(namespace=result)
parser.add_options([PathOption("--test1"),
PathOption("--test2"),
+ PathOption(cf=("test", "test_path")),
+ PathOption(cf=("test", "test_path_default"),
+ default="<repository>/test/default"),
Common.repository])
parser.parse(["-C", config_file, "-Q", "/foo/bar",
"--test1", "<repository>/test1",
@@ -381,6 +385,8 @@ class TestBasicOptions(OptionTestCase):
self.assertEqual(result.repository, "/foo/bar")
self.assertEqual(result.test1, "/foo/bar/test1")
self.assertEqual(result.test2, "/foo/bar/foo/bar")
+ self.assertEqual(result.test_path, "/foo/bar/test")
+ self.assertEqual(result.test_path_default, "/foo/bar/test/default")
@make_config()
def test_file_like_path_option(self, config_file):