diff options
author | holger krekel <holger@merlinux.eu> | 2016-06-20 17:40:38 +0200 |
---|---|---|
committer | holger krekel <holger@merlinux.eu> | 2016-06-20 17:40:38 +0200 |
commit | cef9d6b5edf6c40362b0cf40c81201f7092607c4 (patch) | |
tree | d000893d48950409d5831228e5d559cd9ef4b606 /tests/test_config.py | |
parent | dc11f23e50f7814d332f164892a5f99109a07cb4 (diff) | |
parent | dc873c46cc856c050a7431d68e4e26e98e9de891 (diff) | |
download | tox-cef9d6b5edf6c40362b0cf40c81201f7092607c4.tar.gz |
merge
Diffstat (limited to 'tests/test_config.py')
-rw-r--r-- | tests/test_config.py | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/tests/test_config.py b/tests/test_config.py index 86eb9f1..08b2f23 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -646,6 +646,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(""" @@ -1441,7 +1490,7 @@ class TestGlobalOptions: minversion = 10.0 """ with py.test.raises(tox.exception.MinVersionError): - config = newconfig([], inisource) + newconfig([], inisource) def test_skip_missing_interpreters_true(self, tmpdir, newconfig, monkeypatch): inisource = """ |