0

I have a pyramid application that I am testing using WebTest with the following code:

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)

The view for not found is defined as follow:

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

The coverage for the no found view is:

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

But there is no way that those line were skipped in the test so why coverage missed them?

This is my .coveragerc

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

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

[report]
show_missing = True

I run the test with:

pytest --cov=formshare
QLands
  • 2,424
  • 5
  • 30
  • 50
  • I haven't used pyramid, but if it's like other web frameworks, it spawns a subprocess to run the code. You need to take some extra steps to get subprocesses measured: https://coverage.readthedocs.io/en/latest/subprocess.html – Ned Batchelder Apr 09 '20 at 19:00
  • I tried by adding concurrency = multiprocessing to .coveragerc . Also added a sitecustomize.py to site-packages/ also a .pth to site-packages/ but same behavior – QLands Apr 10 '20 at 13:58

0 Answers0