Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/_perf_config.py @ 619:75ecbe07abff
Introduct a test context to more easily switch between some unittest configurations
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Thu, 13 Jan 2022 11:39:38 +0100 |
| parents | 79db28e879f8 |
| children |
comparison
equal
deleted
inserted
replaced
| 618:8dc514bd3d5e | 619:75ecbe07abff |
|---|---|
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import sys | 6 import sys |
| 7 import timeit | 7 import timeit |
| 8 | 8 |
| 9 sys.path.insert( | 9 from _test_context import TESTDATADIR |
| 10 0, | |
| 11 os.path.abspath( | |
| 12 os.path.normpath(os.path.join(os.path.dirname(__file__), "..")))) | |
| 13 | 10 |
| 14 | 11 |
| 15 opts = sys.argv[1:] | 12 opts = sys.argv[1:] |
| 16 all = not opts or "all" in opts | 13 all = not opts or "all" in opts |
| 17 | 14 |
| 22 fast_unquote = fast_quote = fast_pathstr2path = _fast_split_ns = None | 19 fast_unquote = fast_quote = fast_pathstr2path = _fast_split_ns = None |
| 23 | 20 |
| 24 setup = """ | 21 setup = """ |
| 25 import os | 22 import os |
| 26 | 23 |
| 24 from _test_context import TESTDATADIR | |
| 25 | |
| 27 import configmix | 26 import configmix |
| 28 from configmix.config import _HIER_SEPARATOR, \ | 27 from configmix.config import _HIER_SEPARATOR, \ |
| 29 py_quote, py_unquote, py_pathstr2path, \ | 28 py_quote, py_unquote, py_pathstr2path, \ |
| 30 _py_split_ns | 29 _py_split_ns |
| 31 try: | 30 try: |
| 32 from configmix.config import fast_unquote, fast_quote, fast_pathstr2path, _fast_split_ns | 31 from configmix.config import fast_unquote, fast_quote, fast_pathstr2path, _fast_split_ns |
| 33 except ImportError: | 32 except ImportError: |
| 34 fast_unquote = fast_quote = fast_pathstr2path = _fast_split_ns = None | 33 fast_unquote = fast_quote = fast_pathstr2path = _fast_split_ns = None |
| 35 | |
| 36 TESTDATADIR = os.path.join( | |
| 37 os.path.abspath(os.path.dirname(configmix.__file__)), | |
| 38 "..", | |
| 39 "tests", | |
| 40 "data") | |
| 41 | 34 |
| 42 cfg = configmix.load(os.path.join(TESTDATADIR, "conf_perf.py")) | 35 cfg = configmix.load(os.path.join(TESTDATADIR, "conf_perf.py")) |
| 43 | 36 |
| 44 se = u"" | 37 se = u"" |
| 45 s1 = u"abc.def.hij" | 38 s1 = u"abc.def.hij" |
