我正在尝试在 Windows上设置tox以针对多个 python 安装运行测试。我已将每个 python 安装在名为 的文件夹中C:\Python\PythonXX_YY
,XX
是 python 版本(例如 27)并且YY
是 32 或 64。目前,我的 PATH 中唯一的 python 是C:\Python\Python33_64
,因为我使用新的 python 启动器来运行我想要的任何版本。我也在这个版本中运行 tox。
第一个问题是 tox 没有检测到这些安装,大概是因为它们不在默认位置。我可以通过在 tox.ini 中为每个环境设置路径来解决这个问题,但它使设置非常特定于我的计算机。有没有更好的方法让 tox 知道我的蟒蛇在全球的位置?
第二个问题是,在tox.ini中设置python位置,运行时出现以下错误(对于Python27):
Traceback (most recent call last):
File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 2557, in <module>
main()
File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 961, in main
never_download=options.never_download)
File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 1062, in create_environment
site_packages=site_packages, clear=clear))
File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 1255, in install_python
copy_required_modules(home_dir)
File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 1193, in copy_required_modules
dst_filename = …
Run Code Online (Sandbox Code Playgroud) 我的应用程序依赖于我通过Windows二进制文件在我的系统环境中安装的pywin32.如何从Windows上的tox中的二进制文件安装pywin32等模块?
每当我运行tox时,我的存储库的目录都会被.egg目录破坏.这些显然是我的库所需的依赖项,需要在每个虚拟环境中安装,但我不想看到它们.我不确定他们为什么不去.tox目录...
我没有在'网上看到任何关于此的提示,所以我的问题是:
以下是我的一个Python库的示例:https://github.com/joshvillbrandt/goprohero
谢谢你的帮助!
当我运行tox
命令Sphinx
为我的 Python 项目生成文档时遇到问题。这是错误:
docs runtests: PYTHONHASHSEED='1181019260'
docs runtests: commands[0] | sphinx-build -W -b html -c ./conf.py -d /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/doctrees . /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/html
Error: Config directory doesn't contain a conf.py file.
ERROR: InvocationError: '/Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/bin/sphinx-build -W -b html -c ./conf.py -d /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/doctrees . /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/html'
_________________________________________________ summary __________________________________________________
py27: commands succeeded
lint: commands succeeded
ERROR: docs: commands failed
Run Code Online (Sandbox Code Playgroud)
它基本上是在抱怨conf.py
,但是这个配置文件存在于存在的同一目录中tox.ini
。我是新来的tox
和sphinx
不知道为什么它抱怨。这里是内容tox.ini
。
[tox]
envlist = py27,lint,docs
[testenv]
commands =
python setup.py nosetests --with-coverage --cover-package=limekiln …
Run Code Online (Sandbox Code Playgroud) I'm using tox and py.test to run my Python unittests, and even though I'm using py.test's --tb=long
option, errors are showing like:
E ConftestImportFailure: (local('/myproject/tests/functional_tests/conftest.py'), (<type 'exceptions.ImportError'>, ImportError('No module named blah',), <traceback object at 0x7fb5bb740518>))
Run Code Online (Sandbox Code Playgroud)
Tox is running the command:
py.test -rxs -rf -rs --ff --tb=long -x -k testname
Run Code Online (Sandbox Code Playgroud)
How do I make is show the full traceback? I can't find anything mentioning this in the docs besides the --tb
option.
这是我正在setup.py
为其编写文件的模块的树结构:
ls .
LICENSE
README.md
bin
examples
module
scratch
setup.py
tests
tox.ini
Run Code Online (Sandbox Code Playgroud)
我的配置setup.py
如下:
from setuptools import setup, find_packages
setup(
name="package_name",
version="0.1",
packages=find_packages(),
install_requires=[
# [...]
],
extras_require={
# [...]
},
tests_require={
'pytest',
'doctest'
},
scripts=['bin/bootstrap'],
data_files=[
('license', ['LICENSE']),
],
# [...]
# could also include long_description, download_url, classifiers, etc.
)
Run Code Online (Sandbox Code Playgroud)
如果我从我的 python 环境(也是一个 virtualenv)安装包
pip install .
Run Code Online (Sandbox Code Playgroud)
该LICENSE
文件被正确安装。
但是运行tox
:
[tox]
envlist = py27, py35
[testenv]
deps =
pytest
git+https://github.com/djc/couchdb-python
docopt
commands = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试启动并运行 pyenv (Mac OS X),因此我可以使用 tox/detox 来测试代码与多个 python 环境。我能够安装多个python3版本,然后我pyenv global
在所有版本上使用。这样做之后,pyenv versions
返回这个列表:
system
* 3.2.6 (set by /Users/Workspace/.pyenv/version)
3.3.6
3.4.6
3.5.3
3.6.1
Run Code Online (Sandbox Code Playgroud)
但是,只有 3.4 和 3.5 被识别(以及 2.7.8,我认为它是“系统”):
Geoffreys-MBP:pydnmr-tox Workspace$ python --version
Python 2.7.8
Geoffreys-MBP:pydnmr-tox Workspace$ python3.2 --version
-bash: python3.2: command not found
Geoffreys-MBP:pydnmr-tox Workspace$ python3.3 --version
-bash: python3.3: command not found
Geoffreys-MBP:pydnmr-tox Workspace$ python3.4 --version
Python 3.4.3
Geoffreys-MBP:pydnmr-tox Workspace$ python3.5 --version
Python 3.5.2
Geoffreys-MBP:pydnmr-tox Workspace$ python3.6 --version
-bash: python3.6: command not found
Run Code Online (Sandbox Code Playgroud)
任何想法是什么导致这种行为?tox/detox 同样找不到除了 3.4/3.5 之外的任何 …
这是我的tox.ini:
[tox]
envlist = py27,py35
[testenv]
deps =
Flask
connexion
pytest
coverage
pytest-cov
requests
six
commands=pytest --junitxml xunit-reports/xunit-result-XXX.xml --cov {envsitepackagesdir} --cov-report=xml
[testenv:local]
#HOW DO I SPECIFY A NEW LIST OF PYENV LIKE 31,36 IN HERE????
commands=
pytest --cov {envsitepackagesdir}/XXX --cov-report html
Run Code Online (Sandbox Code Playgroud)
当我运行时,tox
它在py27
和中运行py35
。我想tox -e local
在一组不同的多个python环境中运行。我不知道该怎么做。我该怎么做呢?现在,它甚至不尊重初始环境列表,仅在Python 2.7上运行。
这是我的tox.ini
配置
[tox]
envlist = py36
[testenv]
commands = pytest -vv --pep8 --flakes \
--cov=quest --cov-report \
term-missing --profile {posargs}
deps = -rrequirements.txt
Run Code Online (Sandbox Code Playgroud)
当我运行时tox
,我收到此错误
$ tox
GLOB sdist-make: /Users/hanxue/DrRed/quest-backend/setup.py
py36 inst-nodeps: /Users/hanxue/DrRed/quest-backend/.tox/dist/quest-3.0.0.zip
py36 installed: aniso8601==1.2.1,apipkg==1.4,argon2-cffi==16.3.0,cffi==1.10.0,click==6.7,configparser2==4.0.0,execnet==1.5.0,Flask==0.12.2,Flask-Cors==3.0.3,Flask-JWT==0.3.2,Flask-JWT-Extended==3.3.1,Flask-Login==0.4.0,Flask-RESTful==0.3.6,Flask-SocketIO==2.9.2,Flask-SQLAlchemy==2.3.2,gevent==1.2.2,gevent-websocket==0.10.1,greenlet==0.4.12,httplib2==0.10.3,itsdangerous==0.24,Jinja2==2.9.6,MarkupSafe==1.0,matrix==2.0.1,passlib==1.7.1,pep8==1.7.0,psycopg2==2.7.3,py==1.4.34,pycparser==2.18,pyflakes==1.6.0,PyJWT==1.4.2,pytest==3.2.3,pytest-cache==1.0,pytest-flakes==2.0.0,pytest-flask==0.10.0,pytest-pep8==1.0.6,python-dateutil==2.6.1,python-engineio==1.7.0,python-socketio==1.8.1,pytz==2017.2,quest==3.0.0,six==1.10.0,SQLAlchemy==1.1.12,Werkzeug==0.12.2
py36 runtests: PYTHONHASHSEED='65686078'
py36 runtests: commands[0] | pytest -vv --pep8 --flakes --cov=quest --cov-report term-missing --profile
usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --cov=quest --cov-report --profile
inifile: None
rootdir: /Users/hanxue/DrRed/quest-backend
ERROR: InvocationError: '/Users/hanxue/DrRed/quest-backend/.tox/py36/bin/pytest -vv --pep8 --flakes --cov=quest --cov-report term-missing --profile' …
Run Code Online (Sandbox Code Playgroud) 我有一个 tox.ini 文件
[testenv:py27]
deps= -r{toxinidir}/requirements.txt
setenv =
PYTHONPATH = {toxinidir}{:}{toxinidir}/helpers
Run Code Online (Sandbox Code Playgroud)
我运行了命令tox
,并在里面创建了 virtualenv.tox/py27
当我激活 py27 环境时
cd .tox/py7/bin
source activate
py27 $ echo $PYTHONPATH < gives null>
Run Code Online (Sandbox Code Playgroud)
PYTHONPATH
虽然 tox.ini 已setenv
明确PYTHONPATH
设置但为空
为什么 PYTHONPATH 将自身设置为空?
python ×10
tox ×10
pytest ×2
coverage.py ×1
pyenv ×1
pytest-cov ×1
python-3.x ×1
pywin32 ×1
setuptools ×1
testing ×1
virtualenv ×1