Using py.test with coverage doesn't include imports

前端 未结 5 1966
离开以前
离开以前 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:26

    I fixed the test coverage to 94% by this patch that simplifies import dependencies and by the command:

    py.test --cov jedi test                    # or
    py.test --cov jedi test --cov-report=html  # + a listing with red uncovered lines
    

    Uncovered lines are only in conditional commands or in some less used functions but all headers are completely covered.

    The problem was that the tests configuration test/conftest.py did import prematurely by dependencies almost all files in the project. The conftest file defines also additional command line options and settings that should be set before running the test. Therefore I think that pytest_cov plugin works correctly if it ignores everything that was imported together with this file, although it is a pain. I excluded also __init__.py and settings.py from the report because they are simple and with the complete coverage but they are also imported prematurely in the dependency of conftest.

提交回复
热议问题