PyCharm,Django:零代码覆盖率 [英] PyCharm, Django: zero code coverage

查看:121
本文介绍了PyCharm,Django:零代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PyCharm对Django测试目标具有覆盖运行操作。这将运行测试,但显示的测试覆盖率为零(0%的文件,未在项目窗格中覆盖,在编辑器中为红色)。选中或取消选中使用捆绑的coverage.py没有什么区别。

PyCharm has a "Run with Coverage" action for Django test targets. This runs the tests, but shows zero test coverage (0% files, not covered in the project pane, and all red in the editor). Checking or unchecking "Use bundled coverage.py" makes no difference.

从CLI运行相同的测试可以得到预期的结果:

Running the same tests from the CLI gives the expected results:

$ coverage --version
Coverage.py, version 3.5.1.  http://nedbatchelder.com/code/coverage


$ coverage run ./manage.py test blackbox
Creating test database for alias 'default'...
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s

OK
Destroying test database for alias 'default'...


$ coverage report
Name                      Stmts   Miss  Cover
---------------------------------------------
__init__                      0      0   100%
blackbox/__init__             0      0   100%
blackbox/models               5      0   100%
blackbox/rules/__init__       1      0   100%
blackbox/rules/board         62     19    69%
blackbox/tests               49      6    88%
manage                       11      4    64%
settings                     24      0   100%
---------------------------------------------
TOTAL                       152     29    81%

这可能是什么原因?

推荐答案

如果通过路径中的任何符号链接访问项目,则覆盖范围显示将失败。

If you access your project via any symlink in the path, coverage display will fail.

尝试通过真实路径打开同一项目,您将获得正确的行为。

Try to open same project through real path, and you will get correct behavior.

https://youtrack.jetbrains.com/issue/PY-17616

PS:令人耳目一新的问题,因为错误仍未得到修复。

PS: Refreshing old question, as bug still has not been fixed.

这篇关于PyCharm,Django:零代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆