Skip to content

Testing

This projects provides a few different tests and checks.

In general, we have two files which defines all the tests:

To easily run these tests locally, use:

./scripts/test.sh

If you only want to run the pre-commit hooks manually, use:

uv run prek run --all-files

Running the GitLab CI locally is a bit more complicated. Is also requires Node.js as well as Docker installed and configured.

npm exec gitlab-ci-local
# or run a single job, e.g. pre-commit
npm exec gitlab-ci-local -- pre-commit

Python Code Tests

Feature tests as well as test coverage:

# run tests
uv run coverage run -m unittest discover --start-directory tests

# create html coverage report
uv run coverage html --directory "./build/htmlcov"
# serve html coverage report
uv run python -m http.server -d build/htmlcov

Static code checks using ruff:

# linter
uv run ruff check src
uv run ruff check tests
uv run ruff check scripts
# formatter
uv run ruff format --diff src
uv run ruff format --diff tests
uv run ruff format --diff scripts

To run automatic static code fixes, use:

# linter
uv run ruff check --fix src
uv run ruff check --fix tests
uv run ruff check --fix scripts
# formatter
uv run ruff format src
uv run ruff format tests
uv run ruff format scripts

Static type checks using mypy:

uv run mypy src
uv run mypy tests
uv run mypy scripts

Bash Script Checks

find scripts -type f -name "*.sh" -exec uv run shellcheck --external-sources --shell bash --source-path scripts {} +

Markdown Checks

Verify documentation (markdown) compliance w.r.t. markdown linting rules further specified inside the .markdownlint-cli2.jsonc configuration file.

npm exec markdownlint-cli2 -- "./docs/**/*.md" "./README.md"

License Checks

uv run licensecheck
uv run reuse lint

Vulnerability Checks

uv audit