How to use the tox.config.parseconfig 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 tonybaloney / retox / test / test_ui.py View on Github external
def test_create_layout():
    '''
    Test the creation of layouts with virtual environments
    '''
    screen = MockScreen()
    config = parseconfig([])
    screens, scene, log, host = ui.create_layout(config, screen)
    assert screens is not None
    assert len(screens) == len(config.envlist)
    assert len(log._effects) == len(screens)
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_workdir_gets_resolved(self, tmp_path, monkeypatch):
        """
        Test explicitly setting config path, both with and without the filename
        """
        real = tmp_path / "real"
        real.mkdir()
        symlink = tmp_path / "link"
        symlink.symlink_to(real)

        (tmp_path / "tox.ini").touch()
        monkeypatch.chdir(tmp_path)
        config = parseconfig(["--workdir", str(symlink)])
        assert config.toxworkdir == real
github tox-dev / tox / tests / unit / test_z_cmdline.py View on Github external
def test_summary_status(self, initproj, capfd):
        initproj(
            "logexample123-0.5",
            filedefs={
                "tests": {"test_hello.py": "def test_hello(): pass"},
                "tox.ini": """
            [testenv:hello]
            [testenv:world]
            """,
            },
        )
        config = parseconfig([])
        session = Session(config)
        envs = list(session.venv_dict.values())
        assert len(envs) == 2
        env1, env2 = envs
        env1.status = "FAIL XYZ"
        assert env1.status
        env2.status = 0
        assert not env2.status
        session._summary()
        out, err = capfd.readouterr()
        exp = "{}: FAIL XYZ".format(env1.envconfig.envname)
        assert exp in out
        exp = "{}: commands succeeded".format(env2.envconfig.envname)
        assert exp in out
github tox-dev / tox / tests / unit / test_z_cmdline.py View on Github external
def test_getvenv(self, initproj):
        initproj(
            "logexample123-0.5",
            filedefs={
                "tests": {"test_hello.py": "def test_hello(): pass"},
                "tox.ini": """
            [testenv:hello]
            [testenv:world]
            """,
            },
        )
        config = parseconfig([])
        session = Session(config)
        venv1 = session.getvenv("hello")
        venv2 = session.getvenv("hello")
        assert venv1 is venv2
        venv1 = session.getvenv("world")
        venv2 = session.getvenv("world")
        assert venv1 is venv2
        with pytest.raises(LookupError):
            session.getvenv("qwe")
github tox-dev / tox / src / tox / _pytestplugin.py View on Github external
def create_new_config_file_(args, source=None, plugins=(), filename="tox.ini"):
        if source is None:
            source = args
            args = []
        s = textwrap.dedent(source)
        p = tmpdir.join(filename)
        p.write(s)
        tox.session.setup_reporter(args)
        with tmpdir.as_cwd():
            return parseconfig(args, plugins=plugins)
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_config_bad_pyproject_specified(initproj, capsys):
    base = initproj("config_via_pyproject_legacy-0.5", filedefs={"pyproject.toml": ""})
    with pytest.raises(SystemExit):
        parseconfig(["-c", str(base.join("pyproject.toml"))])

    out, err = capsys.readouterr()
    msg = "ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found\n"
    assert err == msg
    assert "ERROR:" not in out
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
initproj(
            "example123-0.5",
            filedefs={
                "tox.ini": """
            [tox]

            [testenv]
            deps=
                dep1==1.0
                dep2>=2.0
                dep3
                dep4==4.0
            """
            },
        )
        config = parseconfig(
            ["--force-dep=dep1==1.5", "--force-dep=dep2==2.1", "--force-dep=dep3==3.0"]
        )
        assert config.option.force_dep == ["dep1==1.5", "dep2==2.1", "dep3==3.0"]
        expected_deps = ["dep1==1.5", "dep2==2.1", "dep3==3.0", "dep4==4.0"]
        assert expected_deps == [str(x) for x in config.envconfigs["python"].deps]
github tox-dev / tox / tests / unit / config / test_config.py View on Github external
def test_explicit_config_path(self, tmpdir):
        """
        Test explicitly setting config path, both with and without the filename
        """
        path = tmpdir.mkdir("tox_tmp_directory")
        config_file_path = path.ensure("tox.ini")

        config = parseconfig(["-c", str(config_file_path)])
        assert config.toxinipath == config_file_path

        # Passing directory of the config file should also be possible
        # ('tox.ini' filename is assumed)
        config = parseconfig(["-c", str(path)])
        assert config.toxinipath == config_file_path
github theacodes / nox / nox / tox_to_nox.py View on Github external
def main():
    parser = argparse.ArgumentParser(description="Converts toxfiles to noxfiles.")
    parser.add_argument("--output", default="noxfile.py")

    args = parser.parse_args()

    config = tox.config.parseconfig([])
    output = _TEMPLATE.render(config=config, wrapjoin=wrapjoin)

    with io.open(args.output, "w") as outfile:
        outfile.write(output)
github jantman / misc-scripts / toxit.py View on Github external
def parse_toxini(self):
        """parse the tox ini, return dict of environments to list of commands"""
        logger.debug('Calling tox.config.parseconfig()')
        config = parseconfig(args=[])
        logger.debug('Config parsed; envlist: %s', config.envlist)
        env_config = {}
        for envname in config.envlist:
            bindir = os.path.join(
                config.envconfigs[envname].envdir.strpath,
                'bin'
            )
            env_config[envname] = {
                'commands': [],
                'passenv': [x for x in config.envconfigs[envname].passenv],
                'setenv': {
                    a: config.envconfigs[envname].setenv.get(a) for a in
                    config.envconfigs[envname].setenv.keys()
                }
            }
            for cmd in config.envconfigs[envname].commands: