How to use the tox.__version__ 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-venv / tests / test_z_cmdline.py View on Github external
commands_pre = python -c 'print("START")'
            commands = python -c 'print("OK")'
                       - python -c 'raise SystemExit(1)'
                       python -c 'raise SystemExit(2)'
                       python -c 'print("SHOULD NOT HAPPEN")'
            commands_post = python -c 'print("END")'
        """
        },
    )
    json_path = cwd / "res.json"
    result = cmd("--result-json", json_path)
    result.assert_fail()
    data = json.loads(json_path.read_text(encoding="utf-8"))

    assert data["reportversion"] == "1"
    assert data["toxversion"] == tox.__version__

    for env_data in data["testenvs"].values():
        for command_type in ("setup", "test"):
            if command_type not in env_data:
                assert False, "missing {}".format(command_type)
            for command in env_data[command_type]:
                assert isinstance(command["command"], list)
                assert command["output"]
                assert "retcode" in command
                assert isinstance(command["retcode"], int)
        # virtualenv, deps install, package install, freeze
        assert len(env_data["setup"]) == 4
        # 1 pre + 3 command + 1 post
        assert len(env_data["test"]) == 5
        assert isinstance(env_data["installed_packages"], list)
        pyinfo = env_data["python"]
github tox-dev / tox / src / tox / session / __init__.py View on Github external
def runcommand(self):
        reporter.using(
            "tox-{} from {} (pid {})".format(tox.__version__, tox.__file__, os.getpid())
        )
        show_description = reporter.has_level(reporter.Verbosity.DEFAULT)
        if self.config.run_provision:
            provision_tox_venv = self.getvenv(self.config.provision_tox_env)
            return provision_tox(provision_tox_venv, self.config.args)
        else:
            if self.config.option.showconfig:
                self.showconfig()
            elif self.config.option.listenvs:
                self.showenvs(all_envs=False, description=show_description)
            elif self.config.option.listenvs_all:
                self.showenvs(all_envs=True, description=show_description)
            else:
                with self.cleanup():
                    return self.subcommand_test()
github tox-dev / tox / src / tox / config.py View on Github external
raise ValueError("invalid context")

        if config.option.hashseed is None:
            hash_seed = make_hashseed()
        elif config.option.hashseed == "noset":
            hash_seed = None
        else:
            hash_seed = config.option.hashseed
        config.hashseed = hash_seed

        reader.addsubstitutions(toxinidir=config.toxinidir, homedir=config.homedir)
        # As older versions of tox may have bugs or incompatibilities that
        # prevent parsing of tox.ini this must be the first thing checked.
        config.minversion = reader.getstring("minversion", None)
        if config.minversion:
            tox_version = pkg_resources.parse_version(tox.__version__)
            config_min_version = pkg_resources.parse_version(self.config.minversion)
            if config_min_version > tox_version:
                raise tox.exception.MinVersionError(
                    "tox version is {}, required is at least {}".format(
                        tox.__version__, self.config.minversion
                    )
                )

        self.ensure_requires_satisfied(reader.getlist("requires"))

        if config.option.workdir is None:
            config.toxworkdir = reader.getpath("toxworkdir", "{toxinidir}/.tox")
        else:
            config.toxworkdir = config.toxinidir.join(config.option.workdir, abs=True)

        if config.option.skip_missing_interpreters == "config":
github tox-dev / tox / src / tox / _quickstart.py View on Github external
def parse_args():
    parser = argparse.ArgumentParser(
        description="Command-line script to quickly tox config file for a Python project."
    )
    parser.add_argument(
        "root",
        type=str,
        nargs="?",
        default=".",
        help="Custom root directory to write config to. Defaults to current directory.",
    )
    parser.add_argument(
        "--version", action="version", version="%(prog)s {}".format(tox.__version__)
    )
    return parser.parse_args()
github tox-dev / tox / src / tox / venv.py View on Github external
def _getliveconfig(self):
        base_resolved_python_path = self.envconfig.python_info.executable
        version = tox.__version__
        sitepackages = self.envconfig.sitepackages
        develop = self.envconfig.usedevelop
        alwayscopy = self.envconfig.alwayscopy
        deps = []
        for dep in self.get_resolved_dependencies():
            dep_name_md5 = getdigest(dep.name)
            deps.append((dep_name_md5, dep.name))
        base_resolved_python_md5 = getdigest(base_resolved_python_path)
        return CreationConfig(
            base_resolved_python_md5,
            base_resolved_python_path,
            version,
            sitepackages,
            develop,
            deps,
            alwayscopy,
github tox-dev / tox / src / tox / config.py View on Github external
hash_seed = None
        else:
            hash_seed = config.option.hashseed
        config.hashseed = hash_seed

        reader.addsubstitutions(toxinidir=config.toxinidir, homedir=config.homedir)
        # As older versions of tox may have bugs or incompatibilities that
        # prevent parsing of tox.ini this must be the first thing checked.
        config.minversion = reader.getstring("minversion", None)
        if config.minversion:
            tox_version = pkg_resources.parse_version(tox.__version__)
            config_min_version = pkg_resources.parse_version(self.config.minversion)
            if config_min_version > tox_version:
                raise tox.exception.MinVersionError(
                    "tox version is {}, required is at least {}".format(
                        tox.__version__, self.config.minversion
                    )
                )

        self.ensure_requires_satisfied(reader.getlist("requires"))

        if config.option.workdir is None:
            config.toxworkdir = reader.getpath("toxworkdir", "{toxinidir}/.tox")
        else:
            config.toxworkdir = config.toxinidir.join(config.option.workdir, abs=True)

        if config.option.skip_missing_interpreters == "config":
            val = reader.getbool("skip_missing_interpreters", False)
            config.option.skip_missing_interpreters = "true" if val else "false"

        config.ignore_basepython_conflict = reader.getbool("ignore_basepython_conflict", False)
github tox-dev / tox / src / tox / config.py View on Github external
def get_version_info(pm):
    out = ["{} imported from {}".format(tox.__version__, tox.__file__)]
    plugin_dist_info = pm.list_plugin_distinfo()
    if plugin_dist_info:
        out.append("registered plugins:")
        for mod, egg_info in plugin_dist_info:
            source = getattr(mod, "__file__", repr(mod))
            out.append("    {}-{} at {}".format(egg_info.project_name, egg_info.version, source))
    return "\n".join(out)
github tox-dev / tox / src / tox / config / __init__.py View on Github external
def handle_provision(self, config, reader):
        requires_list = reader.getlist("requires")
        config.minversion = reader.getstring("minversion", None)
        config.provision_tox_env = name = reader.getstring("provision_tox_env", ".tox")
        min_version = "tox >= {}".format(config.minversion or tox.__version__)
        deps = self.ensure_requires_satisfied(config, requires_list, min_version)
        if config.run_provision:
            section_name = "testenv:{}".format(name)
            if section_name not in self._cfg.sections:
                self._cfg.sections[section_name] = {}
            self._cfg.sections[section_name]["description"] = "meta tox"
            env_config = self.make_envconfig(
                name, "{}{}".format(testenvprefix, name), reader._subs, config
            )
            env_config.deps = deps
            config.envconfigs[config.provision_tox_env] = env_config
            raise tox.exception.MissingRequirement(config)
        # if provisioning is not on, now we need do a strict argument evaluation
        # raise on unknown args
        self.config._parser.parse_cli(args=self.config.args, strict=True)
github tox-dev / tox / src / tox / config / __init__.py View on Github external
def get_version_info(pm):
    out = ["{} imported from {}".format(tox.__version__, tox.__file__)]
    plugin_dist_info = pm.list_plugin_distinfo()
    if plugin_dist_info:
        out.append("registered plugins:")
        for mod, egg_info in plugin_dist_info:
            source = getattr(mod, "__file__", repr(mod))
            out.append("    {}-{} at {}".format(egg_info.project_name, egg_info.version, source))
    return "\n".join(out)
github tox-dev / tox / tox / session.py View on Github external
def info_versions(self):
        versions = ['tox-%s' % tox.__version__]
        try:
            version = py.process.cmdexec("virtualenv --version")
        except py.process.cmdexec.Error:
            versions.append("virtualenv-1.9.1 (vendored)")
        else:
            versions.append("virtualenv-%s" % version.strip())
        self.report.keyvalue("tool-versions:", " ".join(versions))