Testing
DeepTab uses pytest with pytest-cov for test coverage. The test suite runs against all supported Python versions and operating systems on every push and pull request.
Running the test suite
just test
This expands to:
poetry run pytest --cov=deeptab tests/
To run a single file or a specific test:
poetry run pytest tests/test_models.py -v
poetry run pytest tests/test_models.py::test_tabnet_fit -v
To print live log output and stop on the first failure:
poetry run pytest tests/ -x -s
Test files
File |
What it covers |
|---|---|
|
End-to-end fit/predict cycle for every model |
|
Shared base-class behaviour (sklearn API, |
|
Config dataclass validation and default values |
|
ONNX export and TorchScript tracing |
|
Checkpoint save / load round-trips |
Writing new tests
Place tests in
tests/using thetest_*.pynaming convention.Prefer parametrize over copy-paste for variations of the same test:
import pytest
@pytest.mark.parametrize("n_layers", [1, 2, 4])
def test_depth(n_layers):
...
Use small synthetic datasets (
n=64,d=8) to keep tests fast. Avoid downloading external data in tests.Models rely on PyTorch Lightning internally. To suppress verbose trainer output in tests, set:
import logging
logging.getLogger("lightning.pytorch").setLevel(logging.ERROR)
Coverage
A coverage report is printed to the terminal after every just test run. To generate an interactive HTML report:
poetry run pytest --cov=deeptab --cov-report=html tests/
open htmlcov/index.html
CI test matrix
The ci.yml workflow runs the full suite on every push to main and on every pull request, across:
Dimension |
Values |
|---|---|
Python |
3.10, 3.11, 3.12, 3.13 |
OS |
|
All 12 combinations run in parallel with fail-fast: false, so a failure in one combination does not cancel the others.
Pre-push checks
The pre-commit configuration includes a push-stage hook that runs the full test suite before git push. This is installed automatically by just install. To run it manually:
just check