By now, you’ve got a bunch of tests and doctests set up in your project, which you run with the command:
$ py.test --doctest-modules --cov . --cov-report term-missing
If you happen to have a few script and setup files lying around that you don’t want to test, this might expand to
$ py.test --doctest-modules --cov . --cov-report term-missing --ignore script.py
As you can see, this is getting cumbersome. You can fix this by adding a
setup.cfg file to the root of your project, containing configuration options for your testing. This follows standard INI file syntax.
addopts = –ignore script.py –doctest-modules –cov-report term-missing –cov .
Note that the “ignore” flag only tells pytest not to run that file during testing. You also have to tell the coverage module that you don’t want those lines counted for coverage. Do this in a
.coveragerc file, with similar syntax:
omit = *script.py
Once you’ve done this, you can invoke your tests with a simple, undecorated call to just
That’s it for this entry of my CI series. Follow this blog for the next two entries, setting up Travis CI and Coveralls.