Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/test.py @ 390:0521e857c320
Tests for getfirstintvarl_s()
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 10 Nov 2021 09:38:21 +0100 |
| parents | fe3dfd687621 |
| children | 0b3ffc34fa5c |
comparison
equal
deleted
inserted
replaced
| 389:44ef854da70a | 390:0521e857c320 |
|---|---|
| 703 KeyError, | 703 KeyError, |
| 704 cfg.getfirstvarl_s, | 704 cfg.getfirstvarl_s, |
| 705 {"namespace": None, "path": ["intl" ,"non", "existing"]}, | 705 {"namespace": None, "path": ["intl" ,"non", "existing"]}, |
| 706 {"namespace": None, "path": ["intl", "non", "existing2"]}) | 706 {"namespace": None, "path": ["intl", "non", "existing2"]}) |
| 707 | 707 |
| 708 def test32_getfirstintvarl_s_nonexisting(self): | |
| 709 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | |
| 710 self.assertIsNone(cfg.getfirstintvarl_s( | |
| 711 *(("db", "non", "existing", "key"), | |
| 712 ("db", "non", "existing", "key2"), | |
| 713 ("intl", "non", "existing")), | |
| 714 default=None)) | |
| 715 self.assertRaises( | |
| 716 KeyError, | |
| 717 cfg.getfirstintvarl_s, | |
| 718 ("db", "non", "existing", "key"), | |
| 719 ("db", "non", "exksting", "key2"), | |
| 720 ("intl", "non", "existing")) | |
| 721 | |
| 722 def test33_getfirstintvarl_s_nonexisting(self): | |
| 723 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | |
| 724 self.assertEqual( | |
| 725 20, | |
| 726 cfg.getfirstintvarl_s( | |
| 727 *(("db", "non", "existing", ".key"), | |
| 728 ("db", "non", "existing", "key2"), | |
| 729 ("intl", "non", "existing")), | |
| 730 default=u("20"))) | |
| 731 self.assertEqual( | |
| 732 30, | |
| 733 cfg.getfirstintvarl_s( | |
| 734 *(("db", "non", "existing", "key"), | |
| 735 ("db", "non", "existing", "key2"), | |
| 736 ("intl", "non", "existing")), | |
| 737 default=30)) | |
| 738 self.assertRaises( | |
| 739 KeyError, | |
| 740 cfg.getfirstintvarl_s, | |
| 741 ("db", "non", "existing", "key"), | |
| 742 ("db", "non", "exksting", "key2"), | |
| 743 ("intl", "non", "existing")) | |
| 744 | |
| 745 def test34_getfirstintvarl_s_existing(self): | |
| 746 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | |
| 747 self.assertEqual( | |
| 748 10, | |
| 749 cfg.getfirstintvarl_s( | |
| 750 *(("db", "non", "existing", "key"), | |
| 751 ("intl", "cache", "items"), | |
| 752 ("db", "non", "existing", "key2")), | |
| 753 default=u("20"))) | |
| 754 | |
| 708 | 755 |
| 709 class T02LoadAndMerge(_T02MixinLoadAndMerge, unittest.TestCase): | 756 class T02LoadAndMerge(_T02MixinLoadAndMerge, unittest.TestCase): |
| 710 | 757 |
| 711 def setUp(self): | 758 def setUp(self): |
| 712 self._load = configmix.load | 759 self._load = configmix.load |
