制作"覆盖率报告"只显示当前目录中的文件?

时间:2015-12-11 15:08:19

标签: python django code-coverage

考虑以下示例:

> django-admin startproject testproject
> coverage run ./manage.py test        
Creating test database for alias 'default'...

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...
> coverage report 2>&1 | head -n 20
Name                                                                                                                  Stmts   Miss  Cover
-----------------------------------------------------------------------------------------------------------------------------------------
/home/d/virtualenv/lib/python2.7/site-packages/django/__init__                                                            9      0   100%
/home/d/virtualenv/lib/python2.7/site-packages/django/apps/__init__                                                       2      0   100%
/home/d/virtualenv/lib/python2.7/site-packages/django/apps/config                                                        84     23    73%
/home/d/virtualenv/lib/python2.7/site-packages/django/apps/registry                                                     186     75    60%
/home/d/virtualenv/lib/python2.7/site-packages/django/conf/__init__                                                      87     29    67%
/home/d/virtualenv/lib/python2.7/site-packages/django/conf/global_settings                                              136      0   100%
/home/d/virtualenv/lib/python2.7/site-packages/django/conf/locale/__init__                                                2      0   100%
/home/d/virtualenv/lib/python2.7/site-packages/django/conf/urls/__init__                                                 48     34    29%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/__init__                                                    0      0   100%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/admin/__init__                                             10      0   100%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/admin/actions                                              36     26    28%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/admin/apps                                                 13      0   100%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/admin/checks                                              401    212    47%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/admin/decorators                                           12     11     8%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/admin/exceptions                                            5      0   100%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/admin/filters                                             197    132    33%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/admin/helpers                                             225    161    28%
/home/d/virtualenv/lib/python2.7/site-packages/django/contrib/admin/migrations/0001_initial                               7      0   100%

如何制作"覆盖率报告"只报告当前目录中的文件,即项目文件?

1 个答案:

答案 0 :(得分:2)

尝试使用--source=.或.coveragerc文件中的等效文件。