# HG changeset patch # User Franz Glasner # Date 1642157988 -3600 # Node ID 2426fa273a2950ad397035b0d8e5af1a0598da74 # Parent c56971e854964d5a7c4a304cd983fe5202350cf3 Test defaults for interpolation errors diff -r c56971e85496 -r 2426fa273a29 tests/test.py --- 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",