Using py.test with coverage doesn't include imports

前端 未结 5 1953
离开以前
离开以前 2020-12-14 05:58

For Jedi we want to generate our test coverage. There is a related question in stackoverflow, but it didn\'t help.

We\'re using py.test as a test runner. However, w

5条回答
  •  北海茫月
    2020-12-14 06:21

    @hynekcer gave me the right idea. But basically the easiest solution lies somewhere else:

    Get rid of pytest-cov!

    Use

    coverage run --source jedi -m py.test
    coverage report
    

    instead!!! This way you're just running a coverage on your current py.test configuration, which works perfectly fine! It's also philosophically the right way to go: Make each program do one thing well - py.test runs tests and coverage checks the code coverage.

    Now this might sound like a rant, but really. pytest-cov hasn't been working properly for a while now. Some tests were failing, just because we used it.


    As of 2014, pytest-cov seems to have changed hands. py.test --cov jedi test seems to be a useful command again (look at the comments). However, you don't need to use it. But in combination with xdist it can speed up your coverage reports.

提交回复
热议问题