comparison tests/test.py @ 364:1941f0188e81

FIX: Handle a "default" keyword parameter in ".getvar()" properly. It happened to be a formal parameter but was not used properly within the method body.
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 09 Jul 2021 08:53:30 +0200
parents a5c792074ec9
children 4ff02a4f401a
comparison
equal deleted inserted replaced
363:699072335f63 364:1941f0188e81
438 os.path.join(TESTDATADIR, "conf23.json"), 438 os.path.join(TESTDATADIR, "conf23.json"),
439 os.path.join(TESTDATADIR, "conf24.toml")) 439 os.path.join(TESTDATADIR, "conf24.toml"))
440 x = cfg.expand_variable("{{intl.cache.items|Empty}}") 440 x = cfg.expand_variable("{{intl.cache.items|Empty}}")
441 self.assertEqual(10, x) 441 self.assertEqual(10, x)
442 442
443 def test13_keyerror(self):
444 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"))
445 self.assertRaises(KeyError, cfg.getvar_s, "non.existing.key")
446
447 def test14_getvar_with_default(self):
448 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"))
449 self.assertEqual("999", cfg.getvar("non.existing.key", default="999"))
450
451 def test15_getvar_s_with_default(self):
452 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"))
453 self.assertEqual("999", cfg.getvar_s("non.existing.key",
454 default="999"))
455
456 def test16_getintvar_s_with_default(self):
457 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"))
458 self.assertEqual(9999, cfg.getintvar_s("non.existing.key",
459 default=9999))
460 def test17_getintvar_s_with_default(self):
461 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"))
462 self.assertFalse(cfg.getboolvar_s("non.existing.key",
463 default="false"))
464
443 465
444 class T02LoadAndMerge(_T02MixinLoadAndMerge, unittest.TestCase): 466 class T02LoadAndMerge(_T02MixinLoadAndMerge, unittest.TestCase):
445 467
446 def setUp(self): 468 def setUp(self):
447 self._load = configmix.load 469 self._load = configmix.load