Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/test.py @ 625:f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 13 Jan 2022 22:14:41 +0100 |
| parents | 75ecbe07abff |
| children | c56971e85496 |
comparison
equal
deleted
inserted
replaced
| 624:429a7d5002b8 | 625:f167f8db4624 |
|---|---|
| 446 | 446 |
| 447 def test14_getvar_with_default(self): | 447 def test14_getvar_with_default(self): |
| 448 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 448 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 449 self.assertEqual("999", cfg.getvar("non.existing.key", default="999")) | 449 self.assertEqual("999", cfg.getvar("non.existing.key", default="999")) |
| 450 | 450 |
| 451 def test14_getvar_with_original_default(self): | |
| 452 # The default must be the original and not a copy | |
| 453 dflt = {"foo": "bar"} | |
| 454 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | |
| 455 self.assertTrue(cfg.getvar("non.existing.key", default=dflt) is dflt) | |
| 456 | |
| 451 def test15_getvar_s_with_default(self): | 457 def test15_getvar_s_with_default(self): |
| 452 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 458 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 453 self.assertEqual("999", cfg.getvar_s("non.existing.key", | 459 self.assertEqual("999", cfg.getvar_s("non.existing.key", |
| 454 default="999")) | 460 default="999")) |
| 461 | |
| 462 def test15_getvar_s_with_original_default(self): | |
| 463 # The default must be the original and not a copy | |
| 464 dflt = {"foo2": "bar2"} | |
| 465 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | |
| 466 self.assertTrue(cfg.getvar_s("non.existing.key", default=dflt) is dflt) | |
| 467 | |
| 468 def test15b_getvarl_with_original_default(self): | |
| 469 # The default must be the original and not a copy | |
| 470 dflt = {"foo2": "bar2"} | |
| 471 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | |
| 472 self.assertTrue(cfg.getvarl((u"non", u"existing", u"key"), | |
| 473 default=dflt) is dflt) | |
| 474 | |
| 475 def test15c_getvarl_s_with_original_default(self): | |
| 476 # The default must be the original and not a copy | |
| 477 dflt = {"foo3": "bar3"} | |
| 478 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | |
| 479 self.assertTrue(cfg.getvarl_s((u"non", u"existing", u"key4"), | |
| 480 default=dflt) is dflt) | |
| 455 | 481 |
| 456 def test16_getintvar_s_with_default(self): | 482 def test16_getintvar_s_with_default(self): |
| 457 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 483 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 458 self.assertEqual(9999, cfg.getintvar_s("non.existing.key", | 484 self.assertEqual(9999, cfg.getintvar_s("non.existing.key", |
| 459 default=9999)) | 485 default=9999)) |
