Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/test.py @ 525:be6ef72c55d5
Change Configuration.expand_variable() to Configuration.interpolate_variables()
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Mon, 20 Dec 2021 12:43:17 +0100 |
| parents | ad1e630ba736 |
| children | f71d34dda19f |
comparison
equal
deleted
inserted
replaced
| 524:09b8e28b7a44 | 525:be6ef72c55d5 |
|---|---|
| 415 self.assertEqual("the last value", | 415 self.assertEqual("the last value", |
| 416 cfg.getvarl_s("to-be-deleted-but-reassigned")) | 416 cfg.getvarl_s("to-be-deleted-but-reassigned")) |
| 417 | 417 |
| 418 def test08_None_filter_single(self): | 418 def test08_None_filter_single(self): |
| 419 cfg = self._load() | 419 cfg = self._load() |
| 420 x = cfg.expand_variable("{{non-existing|None}}") | 420 x = cfg.interpolate_variables("{{non-existing|None}}") |
| 421 self.assertIsNone(x) | 421 self.assertIsNone(x) |
| 422 | 422 |
| 423 def test09_None_filter_embedded(self): | 423 def test09_None_filter_embedded(self): |
| 424 cfg = self._load() | 424 cfg = self._load() |
| 425 x = cfg.expand_variable("A{{non-existing|None}}Z") | 425 x = cfg.interpolate_variables("A{{non-existing|None}}Z") |
| 426 self.assertEqual("AZ", x) | 426 self.assertEqual("AZ", x) |
| 427 | 427 |
| 428 def test10_Empty_filtersingle(self): | 428 def test10_Empty_filtersingle(self): |
| 429 cfg = self._load() | 429 cfg = self._load() |
| 430 x = cfg.expand_variable("{{non-existing|Empty}}") | 430 x = cfg.interpolate_variables("{{non-existing|Empty}}") |
| 431 self.assertEqual("", x) | 431 self.assertEqual("", x) |
| 432 | 432 |
| 433 def test11_None_filter_pass_through(self): | 433 def test11_None_filter_pass_through(self): |
| 434 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), | 434 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
| 435 os.path.join(TESTDATADIR, "conf21.yml"), | 435 os.path.join(TESTDATADIR, "conf21.yml"), |
| 436 os.path.join(TESTDATADIR, "conf22.ini"), | 436 os.path.join(TESTDATADIR, "conf22.ini"), |
| 437 os.path.join(TESTDATADIR, "conf23.json"), | 437 os.path.join(TESTDATADIR, "conf23.json"), |
| 438 os.path.join(TESTDATADIR, "conf24.toml")) | 438 os.path.join(TESTDATADIR, "conf24.toml")) |
| 439 x = cfg.expand_variable("{{intl.cache.items|None}}") | 439 x = cfg.interpolate_variables("{{intl.cache.items|None}}") |
| 440 self.assertEqual(10, x) | 440 self.assertEqual(10, x) |
| 441 | 441 |
| 442 def test12_Empty_filter_pass_through(self): | 442 def test12_Empty_filter_pass_through(self): |
| 443 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), | 443 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
| 444 os.path.join(TESTDATADIR, "conf21.yml"), | 444 os.path.join(TESTDATADIR, "conf21.yml"), |
| 445 os.path.join(TESTDATADIR, "conf22.ini"), | 445 os.path.join(TESTDATADIR, "conf22.ini"), |
| 446 os.path.join(TESTDATADIR, "conf23.json"), | 446 os.path.join(TESTDATADIR, "conf23.json"), |
| 447 os.path.join(TESTDATADIR, "conf24.toml")) | 447 os.path.join(TESTDATADIR, "conf24.toml")) |
| 448 x = cfg.expand_variable("{{intl.cache.items|Empty}}") | 448 x = cfg.interpolate_variables("{{intl.cache.items|Empty}}") |
| 449 self.assertEqual(10, x) | 449 self.assertEqual(10, x) |
| 450 | 450 |
| 451 def test13_keyerror(self): | 451 def test13_keyerror(self): |
| 452 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) | 452 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
| 453 self.assertRaises(KeyError, cfg.getvar_s, "non.existing.key") | 453 self.assertRaises(KeyError, cfg.getvar_s, "non.existing.key") |
