Coverage.py warning: No data was collected. (no-data-collected)

后端 未结 6 943
我在风中等你
我在风中等你 2020-12-15 16:40

I am trying to find the coverage using coverage module for a django project but gets

Coverage.py warning: No data was collected. (no-data-collected)
         


        
6条回答
  •  不知归路
    2020-12-15 17:06

    The problem is that you're not specifying which dir to get coverage from.

    You can specify that in the .coveragerc file or on the command line:

    pytest tests -v --cov-report term --cov-report html:htmlcov --cov-report xml --cov-fail-under=90 --cov=
    

    If you desire you can only execute pytest tests and add pytest args on pytest.ini at your project root:

    [pytest]
    addopts = -v --cov-report term --cov-report html:htmlcov --cov-report xml --cov-fail-under= --cov=
    

    Bonus:

    If you want to omit files from the coverage you can add a .coveragerc file on your project root:

    [run]
    omit =
        # omit everything in the folder
        proj-ab/api/confs/
        # omit file
        proj-ab/models/file-not-covered.py
    

    Requirements: On these examples I'm using requirements: pytest==4.6.2 and pytest-cov==2.7.1

提交回复
热议问题