2016-11-25 6 views
0

tox.ini内に任意の変数を設定する方法はありますか?tox.ini変数の作成方法

例は、さまざまな方法で使用されるプロジェクト名です。かなり複雑なtox.iniを使用すると、変数を上に置くだけでどこにコピーして貼り付けることができます。参考のため

、例のtox.ini:

[tox] 
envlist = clean, py{27,35,py}, license, style 
skipsdist = True 
skip_missing_interpreters = True 
sitepackages = False 

[testenv:clean] 
deps = coverage 
skip_install = true 
commands = 
    hash -r 
    find {toxinidir} -name '*.pyc' -delete 
    find {toxinidir} -name '__pycache__' -delete 
    coverage erase 
    rm -Rf {toxinidir}/docs/_build {toxinidir}/docs/coverage {toxinidir}/docs/reports 

[testenv] 
passenv = * 
whitelist_externals = * 
install_command = {envpython} -m pip install -q --process-dependency-links {opts} {packages} 
envdir = {env:WORKON_HOME}/tox-<project_name>/{envname} 
sitepackages = False 
recreate = True 
commands = 
    # hash -r 
    py{27,35,py}: {envpython} -m pytest --cov-append --cov=<project_name> --html=docs/reports/{envname}-report.html {posargs} 
    smoke: {envpython} -m pytest -m smoke --cov-append --cov=<project_name> --html=docs/reports/{envname}-report.html {posargs} 
    unit: {envpython} -m pytest -m unit --cov-append --cov=<project_name> --html=docs/reports/{envname}-report.html {posargs} 
    integration: {envpython} -m pytest -m integration --long-running --cov-append --cov=<project_name> --html=docs/reports/{envname}-report.html {posargs} 
    requirements: {envpython} -m pytest --cov-append --cov=<project_name> --html=docs/reports/{envname}-report.html {posargs} 
    license: {envpython} -m pytest -m license --license --cov-append --html=docs/reports/{envname}-report.html {posargs} 
    py{27,35,py}-smoke: {envpython} -m pytest -m smoke --cov-append --cov=<project_name> --html=docs/reports/{envname}-report.html {posargs} 
    py{27,35,py}-unit: {envpython} -m pytest -m unit --cov-append --cov=<project_name> --html=docs/reports/{envname}-report.html {posargs} 
    py{27,35,py}-integration: {envpython} -m pytest -m integration --long-running --cov-append --cov=<project_name> --html=docs/reports/{envname}-report.html {posargs} 
    py{27,35,py}-requirements: {envpython} -m pytest --cov-append --cov=<project_name> --html=docs/reports/{envname}-report.html {posargs} 
    py{27,35,py}-license: {envpython} -m pytest -m license --cov-append --html=docs/reports/{envname}-report.html {posargs} 
deps = 
    --editable=file:///{toxinidir}[tests] 
    --editable=file:///{toxinidir} 
    py{27,35,py}-requirements: -r{toxinidir}/requirements.txt 


[testenv:coverage-report] 
deps = coverage 
skip_install = true 
whitelist_externals = * 
commands = 
    hash -r 
    coverage combine 
    coverage report -m 

[testenv:docs] 
sitepackages = False 
whitelist_externals = * 
recreate = True 
deps = --editable=file:///{toxinidir}[docs] 
commands = 
    hash -r 
    coverage html --directory=docs/coverage 
    coverage html 
    {envpython} setup.py build_sphinx 

[testenv:style] 
whitelist_externals = * 
sitepackages = False 
recreate = True 
commands = 
    py.test -q --flake8 <project_name>/ --html=docs/reports/{envname}-report.html {posargs} 

[testenv:vagrant] 
passenv = * 
whitelist_externals = * 
sitepackages = False 
recreate = False 
skip_install = true 
changedir = {toxinidir}/provision/vagrant 
commands = 
    hash -r 
    vagrant destroy --force 
    vagrant up 
+0

、この任意の変数はそうあなたがTOXファイル全体で変数を参照することができますか? 1つの場所でそれを定義する。 – idjaw

+0

はい。私は実際に上記の例のプレースホルダを

答えて

2

あなたは{[section]varname}でtox.ini内の変数を参照することができます。

これは、あなたが変数ignore_listで動作することができる方法の例です。明確にするために

[main] 
ignore_list = "E201,E202,E203,E221,E231,E241,E265,E266,E272,E402,W293,W391" 

[testenv] 
commands = 
    pep8 \ 
    --max-line-length=120 \ 
    --ignore={[main]ignore_list}  
+0

と一緒に入れました。あなたは私の一日を作った。ありがとう! –

関連する問題