# HG changeset patch # User Franz Glasner # Date 1556913591 -7200 # Node ID 13527d70e9e3188fb99a9e2b79d535be9932802a # Parent 28e6c1413947af7ab5eb2595577aaa317917d8a7 An additional unit test with a TOML style configuration file diff -r 28e6c1413947 -r 13527d70e9e3 tests/data/conf24.toml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/data/conf24.toml Fri May 03 21:59:51 2019 +0200 @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- + +tmpdir = '{{_tmpdir}}\4' + +[db.user] +name = "the_database_user_2" +__doc2 = "Overwriting a comment" +pwd="the-database-password-2" + +[db.locinfo.ro] +hostname = "3rd-host" diff -r 28e6c1413947 -r 13527d70e9e3 tests/test.py --- a/tests/test.py Fri May 03 21:51:09 2019 +0200 +++ b/tests/test.py Fri May 03 21:59:51 2019 +0200 @@ -223,6 +223,33 @@ u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"), url) + def test02_load_with_toml(self): + cfg = self._load( + os.path.join(TESTDATADIR, "conf20.yml"), + os.path.join(TESTDATADIR, "conf21.yml"), + # .ini replaced with an equivalent .toml + os.path.join(TESTDATADIR, "conf24.toml")) + + self.assertEqual(u("the_database_user_2"), + cfg.getvar_s("db.user.name")) + self.assertEqual(u("the-database-password-2"), + cfg.getvar_s("db.user.pwd")) + + tmpdir = cfg.getvar_s("tmpdir") + self.assertEqual(u(os.getcwd()) + u("/tmp\\4"), tmpdir) + + self.assertEqual(u("3rd-host"), + cfg.getvar_s("db.locinfo.ro.hostname")) + self.assertEqual(u("localhost"), + cfg.getvar_s("db.locinfo.rw.hostname")) + + self.assertEqual(5432, cfg.getvar_s("db.locinfo.ro.port")) + + url = cfg.getvar_s("db.engines.ro.url") + self.assertEqual( + u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"), + url) + def test03_namespace(self): cfg = self._load( os.path.join(TESTDATADIR, "conf20.yml"),