Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/test.py @ 740:cc9dff5fe0ca
Style
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 29 Oct 2023 17:13:32 +0100 |
| parents | 249196bd410a |
| children | e069797f0e36 |
comparison
equal
deleted
inserted
replaced
| 739:249196bd410a | 740:cc9dff5fe0ca |
|---|---|
| 168 cfg.getvar_s("db.user.pwd")) | 168 cfg.getvar_s("db.user.pwd")) |
| 169 | 169 |
| 170 tmpdir = cfg.getvar_s("tmpdir") | 170 tmpdir = cfg.getvar_s("tmpdir") |
| 171 if os.name == 'nt': | 171 if os.name == 'nt': |
| 172 self.assertFalse(u('/') in tmpdir) | 172 self.assertFalse(u('/') in tmpdir) |
| 173 self.assertEqual(os.path.normpath( | 173 self.assertEqual( |
| 174 os.path.abspath(os.path.join(os.getcwd(), "tmp"))), | 174 os.path.normpath( |
| 175 tmpdir) | 175 os.path.abspath( |
| 176 os.path.join(os.getcwd(), "tmp"))), | |
| 177 tmpdir) | |
| 176 | 178 |
| 177 self.assertEqual(u("anotherhost"), | 179 self.assertEqual(u("anotherhost"), |
| 178 cfg.getvar_s("db.locinfo.ro.hostname")) | 180 cfg.getvar_s("db.locinfo.ro.hostname")) |
| 179 self.assertEqual(u("localhost"), | 181 self.assertEqual(u("localhost"), |
| 180 cfg.getvar_s("db.locinfo.rw.hostname")) | 182 cfg.getvar_s("db.locinfo.rw.hostname")) |
| 541 | 543 |
| 542 def test16_getintvar_s_with_default(self): | 544 def test16_getintvar_s_with_default(self): |
| 543 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 545 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 544 self.assertEqual(9999, cfg.getintvar_s("non.existing.key", | 546 self.assertEqual(9999, cfg.getintvar_s("non.existing.key", |
| 545 default=9999)) | 547 default=9999)) |
| 548 | |
| 546 def test17_getintvar_s_with_default(self): | 549 def test17_getintvar_s_with_default(self): |
| 547 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 550 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 548 self.assertFalse(cfg.getboolvar_s("non.existing.key", | 551 self.assertFalse(cfg.getboolvar_s("non.existing.key", |
| 549 default=u('false'))) | 552 default=u('false'))) |
| 550 | 553 |
| 2020 TESTDATADIR, "jail-root-ref.yml")) | 2023 TESTDATADIR, "jail-root-ref.yml")) |
| 2021 jcfg = cfg.jailed(rootpath=("the-root", "ref1")) | 2024 jcfg = cfg.jailed(rootpath=("the-root", "ref1")) |
| 2022 print(repr(jcfg.getvarl_s())) | 2025 print(repr(jcfg.getvarl_s())) |
| 2023 self.assertEqual("v3", jcfg.getvarl_s("ks")) | 2026 self.assertEqual("v3", jcfg.getvarl_s("ks")) |
| 2024 | 2027 |
| 2025 | |
| 2026 def test_referenced_root_2(self): | 2028 def test_referenced_root_2(self): |
| 2027 cfg = configmix.load(os.path.join( | 2029 cfg = configmix.load(os.path.join( |
| 2028 TESTDATADIR, "jail-root-ref.yml")) | 2030 TESTDATADIR, "jail-root-ref.yml")) |
| 2029 jcfg = cfg.jailed(rootpath=("the-root", "ref1")) | 2031 jcfg = cfg.jailed(rootpath=("the-root", "ref1")) |
| 2030 print(repr(jcfg.getvarl_s())) | 2032 print(repr(jcfg.getvarl_s())) |
