WebTest的错误覆盖率报告

时间:2020-04-09 01:12:31

标签: code-coverage webtest

我有一个金字塔应用程序,正在使用WebTest通过以下代码进行测试:

class FunctionalTests(unittest.TestCase):
    def setUp(self):
        from test_app import main        
        app = main({})
        from webtest import TestApp

        self.testapp = TestApp(app)


    def test_not_found(self):
        self.testapp.get("/not_found", status=404)

未找到的视图定义如下:

@notfound_view_config(renderer="../templates/404.jinja2")
def notfound_view(request):
    request.response.status = 404 # This is line 6
    return {}  # This is line 7

找不到视图的范围是:

 Name                                                    Stmts   Miss Branch BrPart  Cover   Missing
  test_app/views/notfound.py                                 4      2      0      0    50%   6-7

但是没有办法在测试中跳过那些行,那么为什么覆盖率错过了它们?

这是我的.coveragerc

[run]
branch = True
source = test_app
# omit = bad_file.py

[paths]
source =
    test_app/
    */site-packages/

[report]
show_missing = True

我通过以下方式运行测试:

pytest --cov=formshare

0 个答案:

没有答案