1

我正在使用 django-nose,它确实生成了一个巨大的覆盖率报告。如果可能的话,我想过滤它的输出。

以下是输出示例:

    (venv) C:\Users\fsantos\Desktop\biskates.com\biskates\biskates_project>python manage.py test biskates --with-coverage
    nosetests --verbosity 1 biskates --with-coverage
    Creating test database for alias 'default'...
    .C:\Users\fsantos\Desktop\biskates.com\venv\lib\site-packages\django\db\models\fields\__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2012-11-21 18:04:49.075000) while time zone support is active.
      RuntimeWarning)
    ....C:\Users\fsantos\Desktop\biskates.com\venv\lib\site-packages\django\db\models\fields\__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime
    (2012-11-21 18:04:51.494000) while time zone support is active.
      RuntimeWarning)
    ...............
    Name
          Stmts   Miss  Cover   Missing
    --------------------------------------------------------------------------------------------------------------------
    biskates.managers
             26      0   100%
    biskates.models
             67      0   100%
    biskates.templatetags
              0      0   100%
    biskates.templatetags.biskates
              1      0   100%
    biskates.views
             90      0   100%
    biskates_project.urls
             19      0   100%
    communication.forms
              9      0   100%
    communication.managers
              9      0   100%
    communication.models
             44      0   100%
    communication.views
             59      0   100%
    debug_toolbar.management
              0      0   100%
    debug_toolbar.middleware
             87     87     0%   4-137
    debug_toolbar.models
              0      0   100%
    debug_toolbar.templatetags
              0      0   100%
    debug_toolbar.toolbar
              0      0   100%
    debug_toolbar.toolbar.loader
             51     51     0%   4-98
    debug_toolbar.urls
              3      3     0%   7-11
    django.conf.locale
              1      1     0%   1
    django.conf.locale.en
              0      0   100%
    django.conf.locale.en.formats
             14     14     0%   7-42
    django.contrib.admin
             19     19     0%   3-41
    django.contrib.admin.actions
             34     34     0%   5-83
    django.contrib.admin.filters
            181    181     0%   8-402
    django.contrib.admin.forms
             27     27     0%   1-43
    django.contrib.admin.helpers
            245    245     0%   1-352
    django.contrib.admin.options
            735    735     0%   1-1464
    django.contrib.admin.sites
            203    203     0%   1-444
    django.contrib.admin.templatetags
              0      0   100%
    django.contrib.admin.templatetags.admin_static
              7      7     0%   1-11
    django.contrib.admin.util
            256    256     0%   1-425
    django.contrib.admin.widgets
            211    211     0%   5-317
    django.contrib.auth.backends
             63     63     0%   1-125
    django.contrib.auth.context_processors
             22     22     0%   4-43
    django.contrib.auth.forms
            175    175     0%   1-335
    django.contrib.auth.hashers
            200    200     0%   1-388
    django.contrib.auth.management
             64     64     0%   4-126
    django.contrib.auth.middleware
             35     35     0%   1-80
    django.contrib.auth.models
            244    244     0%   1-476
    django.contrib.auth.tokens
             33     33     0%   1-71
    django.contrib.contenttypes.generic
            274    274     0%   5-498
    django.contrib.contenttypes.management
             34     34     0%   1-79
    django.contrib.contenttypes.models
             91     91     0%   1-169
    django.contrib.contenttypes.views
             49     49     0%   1-80
    django.contrib.messages.context_processors
              3      3     0%   1-8
    django.contrib.messages.middleware
             11     11     0%   1-26
    django.contrib.messages.models
              0      0   100%
    django.contrib.messages.storage.base
             81     81     0%   1-181
    django.contrib.messages.storage.cookie
             76     76     0%   1-151
    django.contrib.messages.storage.fallback
             29     29     0%   1-54

(...)

            123    123     0%   5-260
    south.v2
              8      8     0%   6-19
    urls
              0      0   100%
    urls.models
             23      2    91%   22, 31
    userprofiles.managers
              4      0   100%
    userprofiles.models
             18      1    94%   14
    userprofiles.views
              4      0   100%
    xml.dom.pulldom
            270    270     0%   1-351
    --------------------------------------------------------------------------------------------------------------------
    TOTAL
           7625   6826    10%
    ----------------------------------------------------------------------
    Ran 20 tests in 10.996s

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

    (venv) C:\Users\fsantos\Desktop\biskates.com\biskates\biskates_project>

为了不损坏您的滚动条,我删除了一半的输出。

正如你所看到的,它非常彻底,它得到了很多我不关心的信息。

我以前使用过 django-test-coverage,但现在我想先将鼻子投入到 django-nose 的优点中,并且不想被束缚在普通的旧 djangoTestCase类的子类中编写测试。

我如何过滤这个巨大的输出?

提前致谢。

4

1 回答 1

3

您可以使用 --cover-package 指定要使用nosetest 覆盖的包,例如:

nosetests --with-coverage --cover-package=herokuapp

仅报告我在 herokuapp 目录中编写的模块。

于 2012-11-21T18:31:31.437 回答