Add a "test-fast" session without the migrations

This commit is contained in:
Alexander Hess 2026-12-06 11:31:48 +01:00
commit 4cc8b332af
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -10,6 +10,7 @@ By default, `uv run nox` runs the sessions that assure code quality:
Further sessions run on demand with `uv run nox -s <session>`:
- "test-fast": Run the test suite without the `alembic` migrations
- "test-with-x.y": Run the test suite with non-main Python versions
- "docs": Build the documentation with `sphinx`
- "venv": Set up the local develop environment in ".venv"
@ -118,6 +119,16 @@ TEST_DEPENDENCIES = (
"pytest-mock",
)
# Arguments the "test" and "test-fast" sessions pass to `pytest` by default
TEST_DEFAULT_ARGS = (
# See "[tool.coverage]" in pyproject.toml for the branch coverage,
# the report format, and the mapping to src/
"--cov",
"--no-cov-on-fail",
"--cov-fail-under=100",
TESTS_LOCATION,
)
# Locations that `mypy` and `pyright` always check as a whole
TYPECHECK_LOCATIONS = (
NOXFILE_LOCATION,
@ -303,18 +314,34 @@ def test_code(session: nox.Session) -> None:
install_pinned(session, *TEST_DEPENDENCIES)
session.run("pytest", "--version")
session.run("pytest", *(session.posargs or TEST_DEFAULT_ARGS))
pytest_default_args = (
# See "[tool.coverage]" in pyproject.toml for the branch coverage,
# the report format, and the mapping to src/
"--cov",
"--no-cov-on-fail",
"--cov-fail-under=100",
TESTS_LOCATION,
@nox.session(name="test-fast", python=MAIN_PYTHON)
def test_code_fast(session: nox.Session) -> None:
"""Run the test suite without the `alembic` migrations.
The database tests run only against `MetaData.create_all()`,
which roughly halves their number => Not for the CI.
Locally, this saves about a third of the run time.
Extra arguments are forwarded to `pytest`.
"""
start(session)
install_pinned(session, *TEST_DEPENDENCIES)
# Must match the "sequentially" param of `db_connection` in tests/conftest.py
# => Otherwise, `-k` deselects nothing, and the entire test suite runs
session.run("pytest", "--version")
session.run(
"pytest",
"-k",
"not sequentially",
*(session.posargs or TEST_DEFAULT_ARGS),
)
session.run("pytest", *(session.posargs or pytest_default_args))
@nox.session(name="test-docstrings", python=MAIN_PYTHON)
def test_docstrings(session: nox.Session) -> None: