tox 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

tox 命令安装:


-bash/zsh: tox: command not found

# Windows (WSL2)
sudo apt-get update sudo apt-get install tox

# Debian
apt-get install tox

# Ubuntu
apt-get install tox

# Arch Linux
pacman -S tox

# Kali Linux
apt-get install tox

# Fedora
dnf install tox

# OS X
brew install tox

# Raspbian
apt-get install tox

# Dockerfile
dockerfile.run/tox

tox 命令补充说明:


tox 命令旨在自动化和标准化 Python 测试。 简化 Python 软件(以及 pytest 和 devpi)的打包、测试和发布过程的更大愿景的一部分。

tox 命令语法:


tox [options] [args ...]

tox 命令选项:


--version
report version information to stdout. (default: False)

-h, --help
show help about options (default: False)

--help-ini, --hi
show help about ini-names (default: False)

-v
increase verbosity of reporting output.-vv mode turns off output redirection for package installation, above level two verbosity flags are passed through to pip (with two less level) (default: 0)

-q
progressively silence reporting output. (default: 0)

--showconfig
show configuration information for all environments. (default: False)

-l, --listenvs
show list of test environments (with description if verbose) (default: False)

-a, --listenvs-all
show list of all defined environments (with description if verbose) (default: False)

-c CONFIGFILE
config file name or directory with 'tox.ini' file. (default: None)

-e envlist
work against specified environments (ALL selects all). (default: None)

--notest
skip invoking test commands. (default: False)

--sdistonly
only perform the sdist packaging activity. (default: False)

-p VAL, --parallel VAL
run tox environments in parallel, the argument controls limit: all, auto - cpu count, some positive number, zero is turn off (default: 0)

-o, --parallel-live
connect to stdout while running environments (default: False)

--parallel--safe-build
(deprecated) ensure two tox builds can run in parallel (uses a lock file in the tox workdir with .lock extension) (default: False)

--installpkg PATH
use specified package for installation into venv, instead of creating an sdist. (default: None)

--develop
install package in the venv using 'setup.py develop' via 'pip -e .' (default: False)

-i URL, --index-url URL
set indexserver url (if URL is of form name=url set the url for the 'name' indexserver, specifically) (default: None)

--pre
install pre-releases and development versions of dependencies. This will pass the --pre option to install_command (pip by default). (default: False)

-r, --recreate
force recreation of virtual environments (default: False)

--result-json PATH
write a json file with detailed information about all commands and results involved. (default: None)

--hashseed SEED
set PYTHONHASHSEED to SEED before running commands. Defaults to a random integer in the range [1, 4294967295] ([1, 1024] on Windows). Passing 'noset' suppresses this behavior. (default: None)

--force-dep REQ
Forces a certain version of one of the dependencies when configuring the virtual environment. REQ Examples 'pytest<2.7' or 'django>=1.6'. (default: None)

--sitepackages
override sitepackages setting to True in all envs (default: False)

--alwayscopy
override alwayscopy setting to True in all envs (default: False)

-s [val], --skip-missing-interpreters [val]
don't fail tests for missing interpreters: {config,true,false} choice (default: config)

--workdir PATH
tox working directory (default: None)

tox 命令实例:


tox 在所有测试环境上运行测试:

tox

tox 创建一个 tox.ini 配置:

tox-quickstart

tox 列出可用的环境:

tox --listenvs-all

tox 在特定环境(例如Python 3.6)上运行测试:

tox -e py36

tox 强制重新创建虚拟环境:

tox --recreate -e py27

tox 扩展阅读:




tox 命令评论