平台规格

多平台基本示例

假设布局如下:

tox.ini      # see below for content
setup.py     # a classic distutils/setuptools setup.py file

以及以下内容 tox.ini 内容:

[tox]
# platform specification support is available since version 2.0
minversion = 2.0
envlist = py{27,36}-{mylinux,mymacos,mywindows}

[testenv]
# environment will be skipped if regular expression does not match against the sys.platform string
platform = mylinux: linux
           mymacos: darwin
           mywindows: win32

# you can specify dependencies and their versions based on platform filtered environments
deps = mylinux,mymacos: py==1.4.32
       mywindows: py==1.4.30

# upon tox invocation you will be greeted according to your platform
commands=
   mylinux: python -c 'print("Hello, Linus!")'
   mymacos: python -c 'print("Hello, Steve!")'
   mywindows: python -c 'print("Hello, Bill!")'

您可以调用 tox 在您的 tox.ini 就住在这里。 tox 创建两个Virtualenv环境, python2.7python3.6 解释器,然后将根据您调用的平台运行指定的命令 tox 在…。