Skip to content

Tests

This document outlines the testing process of opentemplate-based projects.

Features

  • Uses pytest ⧉ for testing.
  • Measures test coverage with pytest-cov ⧉ (default threshold: 100%).
  • Local testing: Runs on the latest three Python versions, following SPEC 0 ⧉.
  • CI testing: Runs across multiple Python versions and OSs (Linux, macOS, Windows) via GitHub Actions.
  • Randomized test execution ensures independence.
  • Includes Hypothesis ⧉ for property-based testing.

Note

tox is not used; instead, tests are run with different interpreters locally and across CI runners.

Writing tests

  • All tests are in the tests directory, named test_.py.
  • Tests should follow pytest style.
  • Recommended: Use Hypothesis ⧉ for property-based testing, as required by OSSF Scorecard ⧉.

Tip

opentemplate does not enforce a specific testing style, but methodologies like Test/Behavior Driven Development may be beneficial.

Checks and fixes

Tests should be documented, formatted, and typed as they will be checked like regular source code.

Tip

See the Python section for more information.

Adjustments

Note

All changes apply to the CI as well.

  • To change coverage requirements, update the fail_under flag in [tool.coverage.reports] section in pyproject.toml
  • To change the test runner, update the tests script in the pyproject.toml file.

Code sources

  • pyproject.toml
  • .github/workflows/tests*.yml
  • .github/workflows/typing*.yml