preventing python coverage from including virtual environment site packages

前端 未结 3 427
天命终不由人
天命终不由人 2021-02-06 20:38

I am new to coverage and ran into a strange problem. My coverage is taking my virtual environment site packages into account. Here is the output of the coverage run:

<         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-06 21:22

    Try using py.test and then specifiying your test options in a setup.cfg file. You will need to pip install pytest first.

    For example:

    [pytest]
    norecursedirs = build docs/_build *.egg .tox *.venv
    python_files = tests/functional* tests/integration*
    addopts =
        #--verbose
        --tb short
        # Turn on --capture to have brief, less noisy output
        # You will only see output if the test fails
        # Use --capture no if you want to see it all or have problems debugging
        --capture fd
        # --capture no
        # show extra test summary info as specified by chars (f)ailed, (E)error,      (s)skipped, (x)failed, (X)passed.
        - rfEsxX
        --junitxml junit.xml
        --cov workspace --cov-report xml --cov-report term-missing
    

    You can read more about configuring py.test here: https://pytest.org/latest/customize.html

提交回复
热议问题