Search code examples
debuggingtox

Running tox under debugger


I am a new volunteer working on an open source project which uses tox for automated testing. As a way of learning, I am interested in seeing how tox calls the functions in the API - what arguments it passes to them, for example. Is there a way to see how it calls the functions being tested?


Solution

  • tox does not execute tests directly, but usually drives a testrunner, e.g. pytest or others.

    e.g. from one of my project's tox.ini

    [testenv]
    description = run the tests with pytest
    extras = test
    commands = pytest {posargs}
    

    You could set a breakpoint via breakpoint() (on Python 3.7 or newer) or via import pdb;pdb.set_trace() in e.g. https://github.com/tox-dev/tox/blob/86a0383c0617ff1d1ea47a526211bedc415c9d95/src/tox/session/commands/run/sequential.py#L67-L76 and step through the process.

    Though, this should not be necessary if you just want to maintain an open source project.

    If you have further questions, we have a pretty decent documentation at https://tox.wiki/en/latest/ and also a friendly chat at https://discord.gg/tox