Coverage.py警告:未收集任何数据. (未收集数据) [英] Coverage.py warning: No data was collected. (no-data-collected)
问题描述
我正在尝试使用django项目的coverage模块查找coverage,但得到
I am trying to find the coverage using coverage module for a django project but gets
Coverage.py warning: No data was collected. (no-data-collected)
我的项目文件夹中有src和tests文件夹.
My project folder has src and tests folders.
我跑步时
coverage run -m pytest && coverage report
它会生成一份报告,覆盖100%的报告,其中包含tests文件夹中的文件列表. 而我跑步时
It produces a report with 100% coverage with the list of files inside the tests folder. Whereas when I run
coverage run --source=src -m pytest && coverage report <br/>
说
Coverage.py warning: No data was collected. (no-data-collected) <br/>
No data to report.
当我尝试在.coveragerc
中给出source=src
或include=src
时,也会出现相同的警告.以上所有情况均通过了测试.
When I try to give the source=src
or include=src
in the .coveragerc
also the same warning occurs. The tests passes for all the above cases.
我想要src文件夹的内容. 是因为我缺少一些路径设置吗?
I want the coverage of the src folder. Is it because I am missing some path setting?
推荐答案
我遇到了同样的问题,问题出在我运行测试的路径上.
I had the same issue and the problem was with the path I was running the tests.
现在正在做什么:
结构
~/Projects/ProjectName
├── manage.py
├── tests
├── src
│ ├── app_one
├── .coveragerc
命令:
~/Projects/ProjectName$ coverage run manage.py test
和我的.coveragerc:
and my .coveragerc:
[run]
include = */src/*
omit = *migrations*, *tests*
plugins = django_coverage_plugin
这篇关于Coverage.py警告:未收集任何数据. (未收集数据)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!