简体   繁体   English

Pytest 和 pytest-cov 引发 CoverageException

[英]Pytest and pytest-cov raise CoverageException

After executing my test suite using Pytest + Pytest-cov I'm getting the following error:使用 Pytest + Pytest-cov 执行我的测试套件后,我收到以下错误:

coverage.misc.CoverageException: Couldn't use data file '/usr/local/myappname/.coverage': Looks like a coverage 4.x data file. coverage.misc.CoverageException:无法使用数据文件“/usr/local/myappname/.coverage”:看起来像覆盖率 4.x 数据文件。 Are you mixing versions of coverage?你在混合不同的覆盖范围吗?

It is weird because fails on my local dev environment but works fine in the testing environment and there is no change in the configuration.这很奇怪,因为在我的本地开发环境中失败但在测试环境中工作正常并且配置没有变化。

Found the issue.发现问题。 pytest-cov uses under the hood coverage and it has updated the local coverage file to sqlite https://coverage.readthedocs.io/en/coverage-5.1/changes.html#version-5-0a6-2019-07-16 . pytest-cov 使用引擎盖覆盖,它已将本地覆盖文件更新为 sqlite https://coverage.readthedocs.io/en/coverage-5.1/changes.html#version-5-0a6-2019-07-16

To solve the issue is as simple as remove the old.coverage file ( rm.coverage ) and re-run your test case.解决这个问题很简单,只需删除 old.coverage 文件 ( rm.coverage ) 并重新运行您的测试用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM