<aside> 💡 This guide applies to the following projects:

Python test runner compatibility

</aside>

Running Tests

To run a pytest-based test suite, run:

# To run with your default Python version (varies by virtualenv)
$ pytest <args>

# To run with a specific Python version, such as 3.9:
$ python3.9 -m pytest <args>

<aside> 💡 Tip: Create aliases in your shell for different Python versions.

For example:

alias pytest2.7="python2.7 -m pytest"
alias pytest3.6="python3.6 -m pytest"
alias pytest3.7="python3.7 -m pytest"
alias pytest3.8="python3.8 -m pytest"
alias pytest3.9="python3.9 -m pytest"
alias pytest3.10="python3.10 -m pytest"

This can make it much easier to run the test suite you want to run.

</aside>

This may take additional arguments for running subsets of tests, debugging tests, filtering warnings, etc. See the sections below.

You can refer to the pytest invocation guide for additional options not covered here (note that not all options may be appropriate for our codebases).

Running Subsets of Tests

Running all unit tests may take a while. To speed up unit testing, there are options to run subsets of tests.

To run only the tests in a specific module: