Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/test.py @ 697:57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 14 Jun 2023 01:11:01 +0200 |
| parents | db764da37cd2 |
| children | 3a9d661d33b5 |
comparison
equal
deleted
inserted
replaced
| 696:8648e0641d60 | 697:57fe110c50c8 |
|---|---|
| 2 | 2 |
| 3 import unittest | 3 import unittest |
| 4 import platform | 4 import platform |
| 5 import io | 5 import io |
| 6 import os | 6 import os |
| 7 import sys | |
| 7 | 8 |
| 8 from _test_context import TESTDATADIR | 9 from _test_context import TESTDATADIR |
| 9 | 10 |
| 10 import configmix | 11 import configmix |
| 11 import configmix.ini | 12 import configmix.ini |
| 285 os.path.join(TESTDATADIR, "conf21.yml"), | 286 os.path.join(TESTDATADIR, "conf21.yml"), |
| 286 os.path.join(TESTDATADIR, "conf22.ini")) | 287 os.path.join(TESTDATADIR, "conf22.ini")) |
| 287 self.assertEqual(u(os.getcwd()), cfg.getvar("OS:cwd")) | 288 self.assertEqual(u(os.getcwd()), cfg.getvar("OS:cwd")) |
| 288 self.assertEqual(u(platform.python_version()), | 289 self.assertEqual(u(platform.python_version()), |
| 289 cfg.getvar_s("PY:version")) | 290 cfg.getvar_s("PY:version")) |
| 291 self.assertEqual(u(sys.prefix), cfg.getvar_s("SYS:prefix")) | |
| 292 self.assertEqual(u(sys.platform), cfg.getvar_s("SYS:platform")) | |
| 293 if hasattr(sys, "base_prefix"): | |
| 294 self.assertEqual(u(sys.base_prefix), | |
| 295 cfg.getvar_s("SYS:base_prefix")) | |
| 296 else: | |
| 297 self.assertRaises(KeyError, cfg.getvar_s, "SYS:base_prefix") | |
| 290 | 298 |
| 291 def test03_namespace_l(self): | 299 def test03_namespace_l(self): |
| 292 cfg = self._load( | 300 cfg = self._load( |
| 293 os.path.join(TESTDATADIR, "conf20.yml"), | 301 os.path.join(TESTDATADIR, "conf20.yml"), |
| 294 os.path.join(TESTDATADIR, "conf21.yml"), | 302 os.path.join(TESTDATADIR, "conf21.yml"), |
| 295 os.path.join(TESTDATADIR, "conf22.ini")) | 303 os.path.join(TESTDATADIR, "conf22.ini")) |
| 296 self.assertEqual(u(os.getcwd()), cfg.getvarl("cwd", namespace="OS")) | 304 self.assertEqual(u(os.getcwd()), cfg.getvarl("cwd", namespace="OS")) |
| 297 self.assertEqual(u(platform.python_version()), | 305 self.assertEqual(u(platform.python_version()), |
| 298 cfg.getvarl_s("version", namespace="PY")) | 306 cfg.getvarl_s("version", namespace="PY")) |
| 307 self.assertEqual(u(sys.prefix), | |
| 308 cfg.getvarl_s("prefix", namespace="SYS")) | |
| 299 | 309 |
| 300 def test04_no_filter(self): | 310 def test04_no_filter(self): |
| 301 cfg = self._load( | 311 cfg = self._load( |
| 302 os.path.join(TESTDATADIR, "conf20.yml"), | 312 os.path.join(TESTDATADIR, "conf20.yml"), |
| 303 os.path.join(TESTDATADIR, "conf21.yml"), | 313 os.path.join(TESTDATADIR, "conf21.yml"), |
