Add a "test-fast" session without the migrations
This commit is contained in:
parent
a36ed34b5e
commit
4cc8b332af
1 changed files with 36 additions and 9 deletions
45
noxfile.py
45
noxfile.py
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue