Skip to content

Commit 24c6738

Browse files
committed
Add testing info to README
- pytest features - pytest plugins - pytest configuration - FastAPI and Starlette testing - test coverage tooling
1 parent 090e15a commit 24c6738

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Brendon Smith ([br3ndonland](https://github.com/br3ndonland/))
2727
- [Logging](#logging)
2828
- [Development](#development)
2929
- [Code style](#code-style)
30+
- [Testing with pytest](#testing-with-pytest)
3031
- [GitHub Actions workflows](#github-actions-workflows)
3132
- [Building development images](#building-development-images)
3233
- [Running development containers](#running-development-containers)
@@ -370,6 +371,23 @@ For more information on Python logging configuration, see the [Python `logging`
370371

371372
- Pre-commit is also useful as a CI tool. The [hooks](.github/workflows/hooks.yml) GitHub Actions workflow runs pre-commit hooks with [GitHub Actions](https://github.com/features/actions).
372373

374+
### Testing with pytest
375+
376+
- Tests are in the _tests/_ directory.
377+
- Run tests by [invoking `pytest` from the command-line](https://docs.pytest.org/en/stable/usage.html) in the root directory of the repo.
378+
- [pytest](https://docs.pytest.org/en/latest/) features used include:
379+
- [fixtures](https://docs.pytest.org/en/latest/fixture.html)
380+
- [monkeypatch](https://docs.pytest.org/en/latest/monkeypatch.html)
381+
- [parametrize](https://docs.pytest.org/en/latest/parametrize.html)
382+
- [`tmp_path`](https://docs.pytest.org/en/latest/tmpdir.html)
383+
- [pytest plugins](https://docs.pytest.org/en/stable/plugins.html) include:
384+
- [pytest-cov](https://github.com/pytest-dev/pytest-cov)
385+
- [pytest-mock](https://github.com/pytest-dev/pytest-mock)
386+
- [pytest configuration](https://docs.pytest.org/en/stable/customize.html) is in _[pyproject.toml](pyproject.toml)_.
387+
- [FastAPI testing](https://fastapi.tiangolo.com/tutorial/testing/) and [Starlette testing](https://www.starlette.io/testclient/) rely on the [Starlette `TestClient`](https://www.starlette.io/testclient/), which uses [Requests](https://requests.readthedocs.io/en/master/) under the hood.
388+
- Test coverage results are reported when invoking `pytest` from the command-line. To see interactive HTML coverage reports, invoke pytest with `pytest --cov-report=html`.
389+
- Test coverage reports are generated within GitHub Actions workflows by [pytest-cov](https://github.com/pytest-dev/pytest-cov) with [coverage.py](https://github.com/nedbat/coveragepy), and uploaded to [Codecov](https://docs.codecov.io/docs) using [codecov/codecov-action](https://github.com/marketplace/actions/codecov). Codecov is then integrated into pull requests with the [Codecov GitHub app](https://github.com/marketplace/codecov).
390+
373391
### GitHub Actions workflows
374392

375393
[GitHub Actions](https://github.com/features/actions) is a continuous integration/continuous deployment (CI/CD) service that runs on GitHub repos. It replaces other services like Travis CI. Actions are grouped into workflows and stored in _.github/workflows_. See my [GitHub Actions Gist](https://gist.github.com/br3ndonland/f9c753eb27381f97336aa21b8d932be6) for more info on GitHub Actions.

0 commit comments

Comments
 (0)