Testing

We use pytest for testing. Please make sure to write tests for any new features or bug fixes you implement.

Execute the test suite

Run the tests from the projet root directory:

pytest

To run tests with coverage report:

pytest -rsx --cov=src tests/
coverage html

The HTML coverage report will be generated in the htmlcov directory (open htmlcov/index.html in a browser to view the report).

Run a specific test file

To run a specific test file, use:

pytest path/to/test_file.py

To run a specific test function in a test file, use:

pytest path/to/test_file.py::test_function_name

Run the test suite in parallel

To run the tests in parallel, you can use the -n option followed by the number of CPU cores you want to use (the pytest-xdist plugin must be installed first):

pytest -n 4

Warning

Be careful when running tests in parallel, as some tests requires GPU memory ressource and may fail if many tests are run simultaneously on the same GPU.