- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个项目,假设名为 'my_project'
具有以下结构:
my_project
|
tox.ini
setup.py
src
|
client.py
server.py
config.json
# other files
tests.py
文件client.py
中定义的类和server.py
使用 config.json
中包含的信息和tests.py
实现py.test
测试文件夹 src 中的每个文件。在客户端/服务器文件中,我读取配置文件如下:
with open('./config.json') as infile:
self.parameters = json.load(infile)
接下来,我创建了一个 tox.ini 文件,如下所示:
[tox]
envlist = py27,cov
[testenv]
#commands = py.test --cov=src/client.py src/tests.py -v
commands = py.test -sv --doctest-modules src/__init__.py src/tests.py
[testenv:py27]
commands = coverage erase
coverage run --source=src -m pytest
coverage report -m
deps = pytest
但是当我运行tox
时命令我收到错误:"No such file or directory: 'config.json'"
。如何设置正确的路径以确保 tox
能找到所有需要的文件吗?
最佳答案
正在尝试打开'./config.json'
总是让 Python 在进程的当前目录中查找;这就是文件路径的工作原理。如果你想打开config.json
文件与 .py
位于同一目录中正在打开的文件,您需要包含包含 .py
的目录的路径文件:
with open(os.path.join(os.path.dirname(__file__), 'config.json')) as infile:
关于python tox - 没有这样的文件或目录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44652995/
我们有一个 tox - 启用项目(我们称之为“主”项目),它依赖于另一个 tox 项目(我们称之为“库”项目)——所有这些都统一在一个存储库中,因为它都是一个大型总体项目的一部分。 项目如何为普通用户
我试图在将命令放入 tox.ini 的 [testenv] Commands = 部分之前验证命令。 是否可以通过将自定义命令作为 shell 参数传递给 tox?类似的东西 tox -e 我尝试
命令: tox -e generated_p27, generated_p35 -- -v -n 5 --dist=loadfile --vcr-record-mode=once 输出 usage:
tl;博士: 我正在为我的一个项目设置 CI,托管在 github 上,使用 tox 和 travis-ci。在构建结束时,我运行 converalls 将覆盖率报告推送到 coveralls.io。
我想使用 setup.py 作为软件包的权限来安装以进行测试,像这样使用 extra_requires 完成: setup( # ... extras_require={
我想为 python 2.6、2.7、3.3 等运行 tox,我正在寻找一种方法来执行此操作,而不像我一样将 python 路径硬编码到项目的 tox.ini 中目前在做: [testenv:py27
描述节继承的 tox 文档在哪里?例如,对于以下内容,[testenv:py27] 继承自 [testenv]: [testenv] command = py.test {toxinidir}/tes
我有一个项目,假设名为 'my_project'具有以下结构: my_project | tox.ini setup.py src | client.py server.py co
tox 是否可以在使用 pip 安装依赖项时避免将输出重定向到文件?我想查看正在安装的内容,因此我想登录到标准输出而不是文件。 最佳答案 如果您想查看每次运行都安装了什么,可以使用 pip freez
我在 tox.ini 中有只应在 Windows 上运行的测试部分。 如何配置 tox 以仅在特定平台上运行测试部分? 最佳答案 Tox 1.8+ 引入了新的 platform 设置。这是来自 the
在tox.ini , 你指定你想要的包 tox安装在它创建的 virtualenvs 中。 [testenv] deps = mock pytest commands = py
tox website 上列出的第一个功能是“使用不同的 Python 版本和解释器检查你的包是否正确安装”。这让我觉得如果我搞砸了我的 setup.py,测试将不会通过,并且我会被提醒我的 setu
我们的 python 项目有一个 requirements.txt 文件,其中列出了一些依赖模块。我们曾经使用过 pip install -r requirements.txt 安装这些依赖项。我们现
根据文档,tox 创建“通过调用 python setup.py sdist 的当前项目的源代码分发”。 我如何配置 tox 使其生成一个轮子,然后将其用于测试?: python setup.py b
我正在使用 pytest 和 tox。我可以使用这样的关键字运行我的一些测试: pytest -k path/to/tests 现在能够使用 tox 也能做到这一点真的很方便,因为那里的环境很干净并
我有一个 tox.ini 文件,想在不同的 django 版本上进行测试: [tox] envlist = py27-django16-{[base]deps] py32-django
我用 tox使用以下基本配置 ( tox.ini ) 测试 python 项目: [tox] envlist = py3 isolated_build = True [testenv] deps =
我的一些测试只在 Linux 下运行,而其他的则可以在任何地方运行。在 Linux 上运行时,我想将最小覆盖率变量设置为比在台式机 Mac 上运行时更高的值。 我怎样才能做到这一点? 这是我的 tox
在我的 tox.ini文件,依赖项通过 requirements.txt 安装setup.py 也使用的文件, 如下: requirements.txt文件包含可接受的范围 django包,取决于安装
我有一个使用诗歌和毒药的Python项目。它有源代码、测试和脚本(juptext 笔记本)。我无法在脚本中导入开发依赖项,但可以在测试中导入。 当我遇到这个问题时,我创建了以下最小示例。一开始不行,后
我是一名优秀的程序员,十分优秀!