如何禁用鼻子测试的覆盖率报告
希望是一个简单的 python/django nose
测试问题,尽管我在 nose
的文档中找不到答案。
使用 ./manage.py test
运行测试后,如何停止显示覆盖率报告?
我的覆盖率报告有一个巨大的问题,迫使我向后滚动几十行以获取失败测试的回溯,这确实中断了我的工作流程!我喜欢使用鼻子,但如果我不知道如何摆脱它,我将不得不回到普通的 django 测试。
预先感谢您的想法!
这是我必须向后滚动才能找到回溯的内容:
./manage.py test
[...]
======================================================================
FAIL: testFreightAveragesContainer ([...].tests.test_average_container.AveragesContainerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "[...]/tests/test_average_container.py", line 32, in testAveragesContainer
121
AssertionError: 12 != 121
Name Stmts Miss Cover Missing
-------------------------------------------------------------------------------------
abc.advertising 0 0 100%
abc.advertising.management 0 0 100%
abc.advertising.models 73 73 0% 1-91
abc.client 0 0 100%
abc.client.admin 200 200 0% 1-430
abc.client.forms 57 57 0% 1-99
abc.client.management 0 0 100%
abc.client.models 434 434 0% 1-1007
abc.client.translations 30 30 0% 1-33
abc.client.views 18 18 0% 1-24
abc.cms 0 0 100%
abc.cms.management 0 0 100%
abc.cms.models 235 235 0% 1-416
abc.cms.translations 18 18 0% 1-21
abc.commodity 0 0 100%
abc.commodity.admin 51 51 0% 1-107
abc.commodity.forms 12 0 100%
abc.commodity.models 343 343 0% 1-669
abc.commodity.search_indexes 10 1 90% 13
abc.commodity.tests 5 3 40% 3-6
abc.commodity.tests.test_average_container 14 1 93% 37
abc.commodity.tests.test_lead_time_analyser 70 0 100%
abc.commodity.tests.test_price_analysers 6 2 67% 10, 15
abc.commodity.translations 38 38 0% 1-40
abc.commodity.urls 11 0 100%
abc.commodity.views 452 359 21% 22-25, 29-32, 74, 83-96, 101-142, 151-159, 166-172, 179-192, 198-250, 260-264, 287-288, 300-314, 321-378, 385-433, 441-502, 509-557, 563-567, 574-581, 587-662, 668-672, 679-686, 694-722, 730-754, 761-843, 850-854, 861-871, 878-904, 951-952, 962-978, 990-1010
abc.data_submission 0 0 100%
abc.data_submission.iron_ore_submission_normalisation 187 187 0% 1-481
abc.data_submission.managers 27 27 0% 1-71
abc.data_submission.models 635 635 0% 1-1222
abc.invoicing 0 0 100%
abc.invoicing.models 261 261 0% 1-440
abc.invoicing.translations 25 25 0% 1-26
abc.localisation 0 0 100%
abc.localisation.management 0 0 100%
abc.localisation.models 167 167 0% 1-528
abc.localisation.translation 0 0 100%
abc.localisation.translation.models 144 144 0% 1-318
abc.localisation.translations 22 22 0% 1-24
abc.mailing 0 0 100%
abc.mailing.admin 110 110 0% 1-165
abc.mailing.forms 33 33 0% 1-44
abc.mailing.management 0 0 100%
abc.mailing.models 337 337 0% 1-706
abc.mailing.translations 15 15 0% 1-16
abc.marketing 0 0 100%
abc.marketing.models 0 0 100%
abc.product 0 0 100%
abc.product.models 0 0 100%
abc.staff 0 0 100%
abc.staff.models 80 80 0% 1-154
.staff.translations 4 4 0% 1-5
abc.utils 0 0 100%
abc.utils.base 9 9 0% 1-19
abc.utils.base.models 187 187 0% 1-435
abc.utils.custom_ui 0 0 100%
abc.utils.custom_ui.advanced_filter 175 175 0% 1-241
abc.utils.custom_ui.models 3 3 0% 1-5
abc.utils.date 41 41 0% 1-73
abc.utils.db 0 0 100%
abc.utils.db.routers 21 19 10% 1-7, 10, 13-32
abc.utils.format 33 33 0% 1-60
abc.utils.models 10 10 0% 1-30
abc.utils.navigation 10 10 0% 2-19
abc.utils.views 23 23 0% 1-42
-------------------------------------------------------------------------------------
TOTAL 4636 4420 5%
----------------------------------------------------------------------
Ran 9 tests in 0.059s
FAILED (failures=1)
./manage.py test commodity --failfast 13.59s user 0.17s system 97% cpu 14.099 total
Hopefully a simple python/django nose
test question, though I can't find the answer in nose
's documentation.
How do I stop the coverage report showing up after I run the tests with ./manage.py test
?
I have a huge problem with the coverage report forcing me to scroll back a few dozen lines to get the traceback of my failing test, it really interrupts my workflow! I like using nose
, but if I can't figure out how to get rid of this I'll have to go back to vanilla django tests.
Thanks in advance for your thoughts!
Here's what I have to scroll back through to get to the traceback:
./manage.py test
[...]
======================================================================
FAIL: testFreightAveragesContainer ([...].tests.test_average_container.AveragesContainerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "[...]/tests/test_average_container.py", line 32, in testAveragesContainer
121
AssertionError: 12 != 121
Name Stmts Miss Cover Missing
-------------------------------------------------------------------------------------
abc.advertising 0 0 100%
abc.advertising.management 0 0 100%
abc.advertising.models 73 73 0% 1-91
abc.client 0 0 100%
abc.client.admin 200 200 0% 1-430
abc.client.forms 57 57 0% 1-99
abc.client.management 0 0 100%
abc.client.models 434 434 0% 1-1007
abc.client.translations 30 30 0% 1-33
abc.client.views 18 18 0% 1-24
abc.cms 0 0 100%
abc.cms.management 0 0 100%
abc.cms.models 235 235 0% 1-416
abc.cms.translations 18 18 0% 1-21
abc.commodity 0 0 100%
abc.commodity.admin 51 51 0% 1-107
abc.commodity.forms 12 0 100%
abc.commodity.models 343 343 0% 1-669
abc.commodity.search_indexes 10 1 90% 13
abc.commodity.tests 5 3 40% 3-6
abc.commodity.tests.test_average_container 14 1 93% 37
abc.commodity.tests.test_lead_time_analyser 70 0 100%
abc.commodity.tests.test_price_analysers 6 2 67% 10, 15
abc.commodity.translations 38 38 0% 1-40
abc.commodity.urls 11 0 100%
abc.commodity.views 452 359 21% 22-25, 29-32, 74, 83-96, 101-142, 151-159, 166-172, 179-192, 198-250, 260-264, 287-288, 300-314, 321-378, 385-433, 441-502, 509-557, 563-567, 574-581, 587-662, 668-672, 679-686, 694-722, 730-754, 761-843, 850-854, 861-871, 878-904, 951-952, 962-978, 990-1010
abc.data_submission 0 0 100%
abc.data_submission.iron_ore_submission_normalisation 187 187 0% 1-481
abc.data_submission.managers 27 27 0% 1-71
abc.data_submission.models 635 635 0% 1-1222
abc.invoicing 0 0 100%
abc.invoicing.models 261 261 0% 1-440
abc.invoicing.translations 25 25 0% 1-26
abc.localisation 0 0 100%
abc.localisation.management 0 0 100%
abc.localisation.models 167 167 0% 1-528
abc.localisation.translation 0 0 100%
abc.localisation.translation.models 144 144 0% 1-318
abc.localisation.translations 22 22 0% 1-24
abc.mailing 0 0 100%
abc.mailing.admin 110 110 0% 1-165
abc.mailing.forms 33 33 0% 1-44
abc.mailing.management 0 0 100%
abc.mailing.models 337 337 0% 1-706
abc.mailing.translations 15 15 0% 1-16
abc.marketing 0 0 100%
abc.marketing.models 0 0 100%
abc.product 0 0 100%
abc.product.models 0 0 100%
abc.staff 0 0 100%
abc.staff.models 80 80 0% 1-154
.staff.translations 4 4 0% 1-5
abc.utils 0 0 100%
abc.utils.base 9 9 0% 1-19
abc.utils.base.models 187 187 0% 1-435
abc.utils.custom_ui 0 0 100%
abc.utils.custom_ui.advanced_filter 175 175 0% 1-241
abc.utils.custom_ui.models 3 3 0% 1-5
abc.utils.date 41 41 0% 1-73
abc.utils.db 0 0 100%
abc.utils.db.routers 21 19 10% 1-7, 10, 13-32
abc.utils.format 33 33 0% 1-60
abc.utils.models 10 10 0% 1-30
abc.utils.navigation 10 10 0% 2-19
abc.utils.views 23 23 0% 1-42
-------------------------------------------------------------------------------------
TOTAL 4636 4420 5%
----------------------------------------------------------------------
Ran 9 tests in 0.059s
FAILED (failures=1)
./manage.py test commodity --failfast 13.59s user 0.17s system 97% cpu 14.099 total
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用哪个版本的 Django 和鼻子?据我所知,这不是Django测试运行的默认行为,也绝对不是nose的默认行为。
提供给nose以切换 使用的相关选项覆盖率插件是“--with-coverage”。
我不确定您是否意外打开了覆盖范围,您应该查看 settings.py
对于 COVERAGE_MODULES 和 TEST_RUNNER 等变量,并查看它们的设置。
Which versions of Django and nose are you using? As far as I'm aware, this is not the default behaviour of Django's test running and it's definitely not default for nose.
The relevant option to give to nose to toggle use of the coverage plugin is "--with-coverage".
I'm not sure you managed to turn coverage on by accident, you should look in settings.py
for variables like COVERAGE_MODULES and TEST_RUNNER and see what they're set to.
您可以:
它对报告选项有更多控制权,除非您要求,否则不会向控制台报告。然后将
--with-coverage
更改为--with-cov
:这只会导出为 html。
这里有同样的问题:
禁用鼻子覆盖报告到 STDOUT何时启用 HTML 报告?
You can:
Which has more control over reporting options and will not report to console unless you ask it to. Then change
--with-coverage
to--with-cov
:This will only export to html.
Same question here:
Disabling nose coverage report to STDOUT when HTML report is enabled?
我不熟悉 Django manage.py 脚本,但我想你可以查看“测试”任务并看到它调用鼻子。我猜您只想运行测试,而不进行覆盖。
鼻子文档在这里 http://somethingaboutorange.com/mrl/projects/nose /0.11.3/usage.html
I am not familiar with Django manage.py script, but I guess that you can look into the "test" task and see hot it calls nose. I guess that you would like to only run the tests, without the coverage.
Nose documentation is here http://somethingaboutorange.com/mrl/projects/nose/0.11.3/usage.html