Running the Test Suite#
To run the test suite for this project, you need to have completed the setup of your development environment as described in the Preparing Your Development Environment topic.
Running the full test suite#
To run the full test suite, use the following command:
uv run --frozen pytest
or use the alias (see Helper Tools for more information):
This command will execute all the tests defined in the project. The test suite is designed to ensure that all components of the project are functioning correctly and to catch any regressions.
Running specific tests#
In case you want to run a specific test or a subset of tests, specify the path to the test file or the test function. For example:
upytest tests/test_module.py
upytest tests/test_module.py::test_function_name
In the first example, all tests in test_module.py will be executed, while in the second example, only the specific test function test_function_name will be run.
Running failed tests only#
If one of the test fails and you want to repeat the test run after you have fixed the issue, use the --lf
/--last-failed
option. For example:
upytest --lf
Interpreting coverage#
Coverage is a measure of how much of your code is executed during the tests. The coverage report is only generated when all tests pass.
[...]
src/docbuild/cli/cmd_validate/process.py 142 3 42 2 97.3% 217->219, 299-303
[...]
src/docbuild/utils/doc.py 20 0 0 0 100.0%
src/docbuild/utils/merge.py 74 0 34 0 100.0%
src/docbuild/utils/paths.py 13 0 6 0 100.0%
--------------------------------------------------------------------------
TOTAL 1866 23 478 6 98.6%
If you look through the report, you will see which lines are not covered by tests indicated by a test coverage lower than 100%. The numbers in the report indicate the line numbers where the code is not executed during the tests.
In this example, the coverage report shows that 98.6% of the code is covered by tests. The file src/docbuild/cli/cmd_validate/process.py
has a coverage of 97.3%, meaning that some lines in this file are not executed during the tests. These lines are indicated by the numbers in the report, such as 217->219
and 299-303
.
Depending on your code, you might want to improve the test coverage by adding more tests for the uncovered lines. This will help ensure that your code is thoroughly tested and behaves as expected.