Search code examples
pythontravis-cicoverage.pypython-coverage

how to know if my Python tests are running in coverage mode?


I am running Ned Batchelder's coverage module on continuous integration using Travis CI but I want to run only integration tests and skip functional ones because they take too long and coverage measurement is not affected by them.

I created a special configuration for this, but I want to know if there is an alternate method of knowing, inside a Python script, is the code is being run by coverage or not.


Solution

  • Travis CI provides a couple of environment variables that can be used for this; in my case any of this will serve:

    CI=true
    TRAVIS=true
    

    even as both answers provided before were really useful, I think this solution is easier to implement for what I need.