我有一个 tox.ini 文件,如下所示:
[testenv]
usedevelop=True
commands =
py.test --quiet {posargs}
deps =
requests
pytest
pytest-cov
pytest-env
oauthlib
PyJWT
python-dateutil
pydispatcher
isodate
[testenv:py27]
deps =
mock
requests
pytest
pytest-cov
pytest-env
oauthlib
PyJWT
python-dateutil
pydispatcher
isodate
[testenv:py33]
basepython = /opt/python3.3/bin/python3.3
Run Code Online (Sandbox Code Playgroud)
其中 py27 和 py33 都继承自 main[testenv]部分。有没有一种方法可以让我不必在继承上指定整个列表,而只需附加,也许是这样的:
deps += mock
Run Code Online (Sandbox Code Playgroud) 我是 Django 和测试的新手,所以请耐心等待。
试图在终端上运行我在 Django 项目中开发的代码的新测试,但不幸的是我继承了几个测试失败(已经通过分析我之前的提交确认了这一点)。我正在尝试运行/修复我的测试/代码。不修复所有失败的测试(至少现在不是)。今天,我们通过tox在主项目文件夹中运行来运行测试,tox 最终py.test使用不同的数据库调用。这是tox.ini配置
[tox]
envlist = unit
skipsdist = True
[testenv:unit]
deps = -rrequirements/test.txt
commands =
bash -c 'TESTING_DB=db.sqlite3 python manage.py initdb --settings telessaude.settings.test'
py.test -n 4
passenv = *
setenv =
DJANGO_SETTINGS_MODULE=telessaude.settings.test
whitelist_externals =
/bin/bash
[flake8]
max-line-length = 110
[pytest]
setenv=
DJANGO_SETTINGS_MODULE=telessaude.settings.test
python_files = **/tests.py **/tests/*.py **/tests.py
norecursedirs = requirements .tox media
Run Code Online (Sandbox Code Playgroud)
这是我的测试,位于 ~/project_name/servicos/tests.py
# encoding: utf-8
from fluxos.tests import BaseFluxoTestCase
from core.tests import BaseTestCase
from servicos.models import Estomatologia …Run Code Online (Sandbox Code Playgroud) 我正在在线阅读并试图理解一些图书馆,我遇到了以下内容:
我在网上阅读,发现了一个tox.ini文件,如下所示:
[tox]
envlist =
py27
py35
py36
py37
flake8
[testenv:flake8]
basepython = python
deps = flake8
commands = flake8 related
[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/related
deps =
-r{toxinidir}/dev-requirements.txt
commands =
pip install -U pip
py.test --basetemp={envtmpdir}
Run Code Online (Sandbox Code Playgroud)
我仍然无法让它运行。我做了以下事情:
pip install -U pip
py.test --basetemp={envtmpdir}
py.tests --basetemp={py37}
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --mccabe --pep8 --flake8
inifile: /home/tmhdev/Documents/related/pytest.ini
rootdir: /home/tmhdev/Documents/related
Run Code Online (Sandbox Code Playgroud)
如何运行此文件中的测试?该库称为相关: https: //github.com/genomoncology/lated/tree/master/tests
我有以下tox.ini文件:
[tox]
envlist = flake8,py{35,36,37,38}{,-keyring}
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
deps =
.[test]
keyring: .[keyring]
setenv =
COVERAGE_FILE = .coverage.{envname}
commands=
pytest {toxinidir}/tests -n 4 {posargs}
[testenv:flake8]
basepython = python3
deps = flake8
commands=
flake8 src tests
[flake8]
ignore: F401,E402,E501,W605,W503
Run Code Online (Sandbox Code Playgroud)
当我运行tox命令,它创建一个.tox含有在指定的每一个环境的文件夹的文件夹[tox]的部分tox.ini。
我想在测试成功后自动读取这些特定文件夹,tox而无需手动运行rm -rf .tox/NAME_OF_THE_ENV。我已经搜索了 tox 文档,但一无所获。
有可能这样做吗?如果是,如何?
我有一个正在运行 tox.ini 文件的 GitHub 操作。该操作的步骤之一是连接到 aws,最后一步是运行 tox
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.key }}
aws-secret-access-key: ${{ secrets.secret_key }}
aws-region: ${{ secretes.region }}
- name: Run tox
run: tox
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我的操作失败并出现以下错误,botocore.exceptions.NoCredentialsError: Unable to locate credentials
我不确定为什么会发生这种情况,特别是因为 aws 配置步骤正在操作中传递
我有一个框架可用于在所有已安装的python版本上运行Python单元测试?
我在我的系统上安装了3个版本的python,我希望能够在所有版本上运行unitests.可执行文件使用"通常"的命名约定:python2.5 python2.7 python3.2
我目前的环境是Windows,但我认为解决方案应该与平台无关.
在tox.ini中,您指定要在其创建的virtualenvs中安装tox的软件包 。
[testenv]
deps =
mock
pytest
commands =
python setup.py test -q
python setup.py flake8
Run Code Online (Sandbox Code Playgroud)
此示例告诉tox在运行测试之前将模拟和pytest安装到每个virtualenv中。Tox将使用pip从PyPI安装那些依赖项。
如何pip install -e从本地结帐而不是PyPI 告诉tox 一种依赖关系?我仍然希望从PyPI安装其余的依赖项。
tox运行我的Python 2.7测试,但是Python 3.4失败了.它给出了"调用失败"消息.摘录:
py34 create: /home/josh/code/ezoutlet/.tox/py34
ERROR: invocation failed (exit code 1), logfile: /home/josh/code/ezoutlet/.tox/py34/log/py34-0.log
ERROR: actionid: py34
msg: getenv
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python3.4', 'py34']
Run Code Online (Sandbox Code Playgroud)
然后
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib/python3.4/base64.py", line 9, in <module>
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible …Run Code Online (Sandbox Code Playgroud) 我是Tox的新手,我想将它设置为在我的项目上运行flake8测试,但是当我尝试运行tox时,我一直收到unicode错误.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 76: ordinal not in range(128)
这是我的tox.ini文件的一个窥视:
[tox]
envlist = flake8
[testenv:flake8]
basepython = python2
skip_install = true
deps =
flake8
commands =
flake8 -v
# Flake8 Configuration
[flake8]
# Ignore some flake8-docstrings errors
# NOTE(sigmavirus24): While we're still using flake8 2.x, this ignore line
# defaults to selecting all other errors so we do not need select=E,F,W,I,D
# Once Flake8 3.0 is released and in a good state, we can …Run Code Online (Sandbox Code Playgroud) 对于我的mpu包,我有执行环境依赖代码,例如
if sys.version_info < (3, 0):
pass # do something
else:
pass # do something else
Run Code Online (Sandbox Code Playgroud)
和一个 tox 文件
[tox]
envlist = py27,py36
[testenv]
deps =
pytest
pytest-cov
pytest-pep8
pydocstyle
commands =
pip install -r test-requirements.txt
pip install -e .[all]
pytest .
pydocstyle
Run Code Online (Sandbox Code Playgroud)
和一个 setup.cfg
[metadata]
description-file = README.md
[tool:pytest]
addopts = ./tests/ --doctest-modules --cov=./mpu --cov-report html:tests/reports/coverage-html --cov-report xml:tests/reports/coverage.xml --pep8 --ignore=docs/
doctest_encoding = utf-8
[pydocstyle]
ignore = D104, D105, D107, D301, D413, D203, D212, D100
match_dir = mpu …Run Code Online (Sandbox Code Playgroud) tox ×10
python ×9
pytest ×2
testing ×2
boto ×1
coverage.py ×1
django ×1
flake8 ×1
inheritance ×1
ini ×1
python-3.7 ×1
unit-testing ×1