How to use the tox.config.SectionReader function in tox

To help you get started, we’ve selected a few tox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_basic_section_access(self, 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"
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_getstring_other_section_substitution(self, newconfig):
        config = newconfig(
            """
            [section]
            key = rue
            [testenv]
            key = t{[section]key}
            """
        )
        reader = SectionReader("testenv", config._cfg)
        x = reader.getstring("key")
        assert x == "true"
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_posargs_are_added_escaped_issue310(self, newconfig):
        config = newconfig(
            """
            [section]
            key= cmd0 {posargs}
        """
        )
        reader = SectionReader("section", config._cfg)
        posargs = ["hello world", "--x==y z", "--format=%(code)s: %(text)s"]
        reader.addsubstitutions(posargs)
        argvlist = reader.getargvlist("key")
        assert argvlist[0] == ["cmd0"] + posargs
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_getstring_fallback_sections(self, newconfig):
        config = newconfig(
            """
            [mydefault]
            key2=value2
            [section]
            key=value
        """
        )
        reader = SectionReader("section", config._cfg, fallbacksections=["mydefault"])
        x = reader.getstring("key2")
        assert x == "value2"
        x = reader.getstring("key3")
        assert not x
        x = reader.getstring("key3", "world")
        assert x == "world"
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_command_section_and_posargs_substitution(self, newconfig):
        """Ensure subsitition from other section with posargs succeeds"""
        config = newconfig(
            """
            [section]
            key = thing arg1
            [testenv]
            commands =
                {[section]key} {posargs} endarg
            """
        )
        reader = SectionReader("testenv", config._cfg)
        reader.addsubstitutions([r"argpos"])
        x = reader.getargvlist("commands")
        assert x == [["thing", "arg1", "argpos", "endarg"]]
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
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"
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_substitution_with_multiple_words(self, newconfig):
        inisource = """
            [section]
            key = pytest -n5 --junitxml={envlogdir}/junit-{envname}.xml []
            """
        config = newconfig(inisource)
        reader = SectionReader("section", config._cfg)
        posargs = ["hello", "world"]
        reader.addsubstitutions(posargs, envlogdir="ENV_LOG_DIR", envname="ENV_NAME")

        expected = ["pytest", "-n5", "--junitxml=ENV_LOG_DIR/junit-ENV_NAME.xml", "hello", "world"]
        assert reader.getargvlist("key")[0] == expected
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_getstring_substitution(self, newconfig):
        config = newconfig(
            """
            [mydefault]
            key2={value2}
            [section]
            key={value}
        """
        )
        reader = SectionReader("section", config._cfg, fallbacksections=["mydefault"])
        reader.addsubstitutions(value="newvalue", value2="newvalue2")
        x = reader.getstring("key2")
        assert x == "newvalue2"
        x = reader.getstring("key3")
        assert not x
        x = reader.getstring("key3", "{value2}")
        assert x == "newvalue2"
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_command_substitution_from_other_section(self, newconfig):
        config = newconfig(
            """
            [section]
            key = whatever
            [testenv]
            commands =
                echo {[section]key}
            """
        )
        reader = SectionReader("testenv", config._cfg)
        x = reader.getargvlist("commands")
        assert x == [["echo", "whatever"]]
github tox-dev / tox-travis / src / tox_travis / envlist.py View on Github external
def override_ignore_outcome(ini):
    """Decide whether to override ignore_outcomes."""
    travis_reader = tox.config.SectionReader("travis", ini)
    return travis_reader.getbool('unignore_outcomes', False)