Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/test.py @ 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 | db3ff4fbb4ce |
comparison
equal
deleted
inserted
replaced
| 628:c56971e85496 | 629:2426fa273a29 |
|---|---|
| 463 # The default must be the original and not a copy | 463 # The default must be the original and not a copy |
| 464 dflt = {"foo2": "bar2"} | 464 dflt = {"foo2": "bar2"} |
| 465 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 465 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 466 self.assertTrue(cfg.getvar_s("non.existing.key", default=dflt) is dflt) | 466 self.assertTrue(cfg.getvar_s("non.existing.key", default=dflt) is dflt) |
| 467 | 467 |
| 468 def test15_getvar_s_substituting_error_with_original_default(self): | |
| 469 # The default must be the original and not a copy | |
| 470 dflt = {"foo22": "bar22"} | |
| 471 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | |
| 472 # exists ... | |
| 473 cfg.getvar(u"intl.localedir") | |
| 474 # ... but cannot interpolated | |
| 475 self.assertTrue(cfg.getvar_s(u"intl.localedir", default=dflt) is dflt) | |
| 476 | |
| 468 def test15b_getvarl_with_original_default(self): | 477 def test15b_getvarl_with_original_default(self): |
| 469 # The default must be the original and not a copy | 478 # The default must be the original and not a copy |
| 470 dflt = {"foo2": "bar2"} | 479 dflt = {"foo2": "bar2"} |
| 471 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 480 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 472 self.assertTrue(cfg.getvarl(u"non", u"existing", u"key", | 481 self.assertTrue(cfg.getvarl(u"non", u"existing", u"key", |
| 475 def test15c_getvarl_s_with_original_default(self): | 484 def test15c_getvarl_s_with_original_default(self): |
| 476 # The default must be the original and not a copy | 485 # The default must be the original and not a copy |
| 477 dflt = {"foo3": "bar3"} | 486 dflt = {"foo3": "bar3"} |
| 478 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 487 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 479 self.assertTrue(cfg.getvarl_s(u"non", u"existing", u"key4", | 488 self.assertTrue(cfg.getvarl_s(u"non", u"existing", u"key4", |
| 489 default=dflt) is dflt) | |
| 490 | |
| 491 def test15d_getvarl_s_substituting_error_with_original_default(self): | |
| 492 dflt = {"foo4": "bar4"} | |
| 493 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | |
| 494 # key exists ... | |
| 495 cfg.getvarl(u"intl", u"localedir") | |
| 496 # ... but cannot interpolated | |
| 497 self.assertTrue(cfg.getvarl_s(u"intl", u"localedir", | |
| 480 default=dflt) is dflt) | 498 default=dflt) is dflt) |
| 481 | 499 |
| 482 def test16_getintvar_s_with_default(self): | 500 def test16_getintvar_s_with_default(self): |
| 483 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 501 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 484 self.assertEqual(9999, cfg.getintvar_s("non.existing.key", | 502 self.assertEqual(9999, cfg.getintvar_s("non.existing.key", |
