我有以下 tox.ini 組態檔:
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
envlist = py27, py37, pycodestyle, pylint
[testenv]
commands =
pytest --junitxml=unit-tests.xml --cov=xivo --cov-report term --cov-report xml:coverage.xml xivo
deps =
-rrequirements.txt
-rtest-requirements.txt
pytest-cov
[testenv:pycodestyle]
# E501: line too long (80 chars)
commands =
-sh -c 'pycodestyle --ignore=E501 xivo > pycodestyle.txt'
deps =
pycodestyle
whitelist_externals =
sh
[testenv:pylint]
commands =
-sh -c 'pylint --rcfile=/usr/share/xivo-ci/pylintrc xivo > pylint.txt'
deps =
-rrequirements.txt
-rtest-requirements.txt
pylint
whitelist_externals =
sh
[testenv:black]
skip_install = true
deps = black
commands = black --skip-string-normalization .
[testenv:linters]
skip_install = true
deps =
flake8
flake8-colors
black
commands =
black --skip-string-normalization --check .
flake8
[testenv:integration]
basepython = python3.7
usedevelop = true
deps = -rintegration_tests/test-requirements.txt
changedir = integration_tests
passenv =
WAZO_TEST_DOCKER_OVERRIDE_EXTRA
commands =
make test-setup
pytest -v {posargs}
whitelist_externals =
make
sh
[flake8]
# E501: line too long (80 chars)
# W503: line break before binary operator
# E203: whitespace before ':' warnings
# NOTE(sileht):
# * xivo_config.py not python3 ready
exclude = .tox,.eggs,xivo/xivo_config.py
show-source = true
ignore = E501, E203, W503
max-line-length = 99
application-import-names = xivo
我已經更新了我的 requirements.txt 檔案,以便將 Marshmallow 的版本從 3.0.0b14 升級到 3.10.0;像這樣:
https://github.com/wazo-platform/wazo-lib-rest-client/archive/master.zip
https://github.com/wazo-platform/wazo-auth-client/archive/master.zip
https://github.com/wazo-platform/xivo-bus/archive/master.zip
cheroot==6.5.4
flask==1.0.2
netifaces==0.10.4
psycopg2==2.7.7
pyyaml==3.13
python-consul==1.1.0
marshmallow==3.10.0
six==1.12.0
stevedore==1.29.0
現在我的問題是,當我運行tox -e py37一切正常時,但是當我運行這個命令時tox -e py27,它失敗了。我知道問題是 Python 2.7 不支持 Marshmallow 3.10.0;所以我想做的是更改tox.ini檔案以便在運行此命令時忽略 Marshmallow 庫測驗tox -e py27。我是tox的新手,所以我不知道該怎么做。歡迎任何幫助,謝謝。
uj5u.com熱心網友回復:
您需要用pytest記號筆標記那些“棉花糖”測驗。
https://docs.pytest.org/en/6.2.x/example/markers.html
例如
@pytest.mark.marshmellow
def test_xxx():
...
然后你需要運行pytest -m "not marshmellow".
由于您只想為 Python 2.7 執行此操作,因此您需要創建一個新的 testenv。
例如
[testenv:py27]
commands = pytest -m "not marshmellow" ...
uj5u.com熱心網友回復:
支持 Python 2.7 的最后一個 Marshmallow 版本是 2.21.0。您可以標記您requirements.txt為不同版本的 Python 安裝不同版本的 Marshmallow:
marshmallow<3; python_version == '2.7'
marshmallow==3.10.0; python_version >= '3.6'
見https://www.python.org/dev/peps/pep-0496/
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/421460.html
標籤:
