Search code examples
pythonunit-testingnosecoverage.py

Configure tests and coverage to run at setup


I'm supposed to configure a python package with tests and coverage.

Now, I can successfully run tests (with nosetest) and coverage (through coverage.py), but I'm a little confused on how to make them run automatically, when the package is installed or updated.

I've searched online and I edited my setup.py file so it looks something like this:

    ...
    test_suite='nose.collector',
    setup_requires=['nose>=1.0','coverage>=1.0'],
    tests_require=['nose'],
    ...

My confusion is such that I cannot even understand if this is enough to make it work. Any help will be appreciated.


Solution

  • My guess is that you are after a Continuous integration solution like Travis CI (or any other) that installs and runs your package against the test suite in every branch (including master).

    You can take a look in GitHub at how other open source projects are doing it, for example aiohttp:

    aiohttp is running their CI pipeline in Travis CI:

    • The configuration is at .travis.yml
    • As you can see there, it is executing the test suite through the Makefile

    Another project doing something similar is flask