diff options
author | Walter Scheper <Walter.Scheper@sas.com> | 2016-03-10 21:43:49 -0500 |
---|---|---|
committer | Walter Scheper <Walter.Scheper@sas.com> | 2016-03-10 21:43:49 -0500 |
commit | f580e1a594f220b974abe0a2de85339f479c0542 (patch) | |
tree | 4e94416f7f71f44a4e54bbccce9e5962b72a99c0 /tests | |
parent | ab4346fba2a7f92f0a742df624c32ea3ff9767fd (diff) | |
download | tox-f580e1a594f220b974abe0a2de85339f479c0542.tar.gz |
Support configuration through setup.cfgconfig-in-setup-cfg
When the usual search for a config file fails, try loading setup.cfg
with a section prefix of tox. Modeled on coverage's use of setup.cfg as
an alternative config file.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_config.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py index 372cd4f..a7ddb12 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -632,6 +632,55 @@ class TestIniParser: py.test.raises(tox.exception.ConfigError, 'reader.getbool("key5")') +class TestIniParserPrefix: + def test_basic_section_access(self, tmpdir, newconfig): + config = newconfig(""" + [p:section] + key=value + """) + reader = SectionReader("section", config._cfg, prefix="p") + x = reader.getstring("key") + assert x == "value" + assert not reader.getstring("hello") + x = reader.getstring("hello", "world") + assert x == "world" + + def test_fallback_sections(self, tmpdir, newconfig): + config = newconfig(""" + [p:mydefault] + key2=value2 + [p:section] + key=value + """) + reader = SectionReader("section", config._cfg, prefix="p", + fallbacksections=['p:mydefault']) + x = reader.getstring("key2") + assert x == "value2" + x = reader.getstring("key3") + assert not x + x = reader.getstring("key3", "world") + assert x == "world" + + def test_value_matches_prefixed_section_substituion(self): + assert is_section_substitution("{[p:setup]commands}") + + def test_value_doesn_match_prefixed_section_substitution(self): + assert is_section_substitution("{[p: ]commands}") is None + assert is_section_substitution("{[p:setup]}") is None + assert is_section_substitution("{[p:setup] commands}") is None + + def test_other_section_substitution(self, newconfig): + config = newconfig(""" + [p:section] + key = rue + [p:testenv] + key = t{[p:section]key} + """) + reader = SectionReader("testenv", config._cfg, prefix="p") + x = reader.getstring("key") + assert x == "true" + + class TestConfigTestEnv: def test_commentchars_issue33(self, tmpdir, newconfig): config = newconfig(""" |