nose-devs / nose

nose is nicer testing for python
http://readthedocs.org/docs/nose/en/latest/
1.36k stars 397 forks source link

nosetests exclude_lines #1082

Closed Ademord closed 6 years ago

Ademord commented 6 years ago

Hello! I am trying to exclude code in the tox report, from what I gathered online I am trying to use the following in my tox.ini file:

[report]
exclude_lines=
    pragma: no cover
    pragma: ${MYSQL_TESTS} cover

But it doesn't seem to work, especially for the environment variable (spawning a docker container where I run all tests), for example MYSQL_TESTS=NO.

On my code i have it something like

This report right here:

screenshot 2018-06-13 10 02 18

The way I run my tests is:

[tox]
envlist = py36
setupdir = /app/src/

[testenv]
passenv = *

deps =
        --upgrade
        -r/app/src/requirements.txt
        -r/app/tests/requirements.txt

commands =
        nosetests -w /app/tests --with-xunit --xunit-file=/output/nosetests.xml \
            --with-coverage --cover-erase \
            --cover-package=adapters --cover-package=esm \
            --cover-min-percentage=70
        codecov -e TOXENV

Could someone help me out please? Am i setting this wrong?

Ademord commented 6 years ago

So I managed to get it working by using:

[coverage:report] 
exclude_lines=
    pragma: no cover
    pragma: ${MYSQL_TESTS} cover

Since I am reading the config out of a tox.ini, i need the "coverage" prefix. It is important 😄!