pythontestingsetup.pytox

tox tests, use setup.py extra_require as tox deps source


I want to use setup.py as the authority on packages to install for testing, done with extra_requires like so:

setup(
    # ...
    extras_require={
        'test': ['pytest', ],
    },
)

Tox only appears to be capable of installing from a requirements.txt file which just implies a step of snapshotting requirements before testing (which I'm ignorant how to do automatically) or by duplicating the test dependencies into the tox file, which is all I want to avoid. One mailing list post suggested that tox.ini should be the authority on test dependencies, but I don't wish to straightjacket tox into the project that completely.


Solution

  • You now have the "extras" option:

    # tox.ini
    ...
    [testenv]
    ...
    extras = test
    

    Source: https://tox.wiki/en/latest/config.html#extras