基于覆盖率数据的测试排除pytest插件
项目描述
Coverage-based test exclusion plugin for pytest. By looking at which lines are executed by each test, the next test run can be sped up by not executing the tests where no source files have changed.
If you have a large test suite which you often re-run, this plugin can drastically improve the iteration times.
安装
使用pip安装
$ pip install pytest-cov-exclude
pytest-cov-exclude需要Pytest 2.8或更高版本。它与Python 2.7、3.3、3.4、3.5以及PyPy兼容。由于覆盖率数据生成的未知错误,它不支持PyPy 3。
使用方法
第一次运行测试套件时,将启用每个测试的覆盖率,并且套件将比通常情况下运行得稍长
$ py.test
==================== test session starts =====================
# Test output...
================ MANY passed in MANY seconds =================
现在当您重新运行测试套件时,所有测试都应被排除
$ py.test
==================== test session starts =====================
# Test output...
=============== MANY deselected in FEW seconds ===============
如果测试失败,即使没有任何更改也将重新运行,以保留测试套件的总体失败状态。
强制单个测试包含
如果您有依赖于不在覆盖率数据中的文件(如数据文件或生成的源代码)的测试,可以使用 external_dependencies 标记测试。这会强制它们即使没有文件更改也要重新运行。
@pytest.mark.external_dependencies
def test_something():
# Run tests from external data files
已知问题
在 pytest 收集阶段对文件的更改将被忽略。测试文件及其依赖关系将在测试收集完成后尽可能快地进行扫描。
有一个标记为 xfail 的测试用例,它突出了这个问题。
运行整个测试套件
如果您想强制重新运行整个测试套件,您有两种选择:或者禁用插件,或者清除 pytest 的缓存。
$ py.test -p no:cov-exclude # Disable the plugin
$ py.test --cache-clear # Clear pytest's cache
兼容性
如前所述,此插件需要 Pytest 2.8 或更高版本,因为它依赖于新的缓存模块。
虽然支持 PyPy,但用于更快速序列化和反序列化的 ujson 库不可用,因此将回退到默认的 JSON 实现。因此,在 PyPy 下使用此插件时,测试实际上可能运行得更慢。
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于 安装软件包 的信息。
源代码分发
构建分发
pytest-cov-exclude-0.0.9.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f67e3a0ef44160e6b9ceb36902cee68a64d328a0a61b1b7fe881414f4c94fa88 |
|
MD5 | 85d68987c7581ced152817fce65389b8 |
|
BLAKE2b-256 | 3e55e4c346205bc51efe8632fc419b15349a8ea297fe32fce03bf684c10e2d0c |
pytest_cov_exclude-0.0.9-py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e5e373c4e5b13a43b5f2d7ec4baf68af4fcdedd4097702cb7983475a95fd4b25 |
|
MD5 | 020d94d68423db21f440c674aa00504e |
|
BLAKE2b-256 | 2127c63af4ce00ce26000ac82e78228f7de4f273e54f3c628aa79d9699abaabd |