summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2014-10-22 13:02:35 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2014-11-10 17:35:44 -0600
commit3d26097342ecbda755135dc3cf39517d75c027aa (patch)
tree334936b918b16a1128dcc14e37d242d969ae0352 /testsuite
parentb50d7b239f5b6530873df25a80dde484f955581c (diff)
downloadbcfg2-3d26097342ecbda755135dc3cf39517d75c027aa.tar.gz
bcfg2-3d26097342ecbda755135dc3cf39517d75c027aa.tar.bz2
bcfg2-3d26097342ecbda755135dc3cf39517d75c027aa.zip
Options: fix path canonicalization and file-like objects
This fixes canonicalizing PathOption values when the default value of a config file-only option is used. It also fixes PathOptions that get a file-like object instead of a filename string.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/Testsrc/Testlib/TestOptions/TestOptions.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
index 94d30dd3a..a3190f2ca 100644
--- a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
+++ b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
@@ -75,6 +75,20 @@ class TestBasicOptions(OptionTestCase):
self.assertEqual(options.test_path_option,
os.path.abspath("./test"))
+ @make_config()
+ def test_default_path_canonicalization(self, config_file):
+ """canonicalize default PathOption values."""
+ testdir = os.path.expanduser("~/test")
+ result = argparse.Namespace()
+ parser = Parser(namespace=result)
+ parser.add_options([PathOption("--test1", default="~/test"),
+ PathOption(cf=("test", "test2"),
+ default="~/test"),
+ Common.repository])
+ parser.parse(["-C", config_file])
+ self.assertEqual(result.test1, testdir)
+ self.assertEqual(result.test2, testdir)
+
def test_default_bool(self):
"""use the default value of boolean options."""
options = self._test_options()