changeset 629:2426fa273a29

Test defaults for interpolation errors
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 14 Jan 2022 11:59:48 +0100
parents c56971e85496
children 33264c660fca
files tests/test.py
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test.py	Fri Jan 14 11:57:06 2022 +0100
+++ b/tests/test.py	Fri Jan 14 11:59:48 2022 +0100
@@ -465,6 +465,15 @@
         cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"))
         self.assertTrue(cfg.getvar_s("non.existing.key", default=dflt) is dflt)
 
+    def test15_getvar_s_substituting_error_with_original_default(self):
+        # The default must be the original and not a copy
+        dflt = {"foo22": "bar22"}
+        cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"))
+        # exists ...
+        cfg.getvar(u"intl.localedir")
+        # ... but cannot interpolated
+        self.assertTrue(cfg.getvar_s(u"intl.localedir", default=dflt) is dflt)
+
     def test15b_getvarl_with_original_default(self):
         # The default must be the original and not a copy
         dflt = {"foo2": "bar2"}
@@ -479,6 +488,15 @@
         self.assertTrue(cfg.getvarl_s(u"non", u"existing", u"key4",
                                       default=dflt) is dflt)
 
+    def test15d_getvarl_s_substituting_error_with_original_default(self):
+        dflt = {"foo4": "bar4"}
+        cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"))
+        # key exists ...
+        cfg.getvarl(u"intl", u"localedir")
+        # ... but cannot interpolated
+        self.assertTrue(cfg.getvarl_s(u"intl", u"localedir",
+                                      default=dflt) is dflt)
+
     def test16_getintvar_s_with_default(self):
         cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"))
         self.assertEqual(9999, cfg.getintvar_s("non.existing.key",