chore(tests): speed up pytest from >2min to ~12s

- Default-off coverage in pyproject.toml addopts; opt-in via make test-cov
- Add pytest-xdist for parallel execution (make test = pytest -nauto --no-cov)
- Promote API test fixtures to session/module scope (engine, app, mocks);
  per-test isolation via table truncation instead of schema rebuild
- Remove Makefile include .env/export that leaked config vars into tests;
  docker-compose reads .env natively
- Add _ignore_dotenv autouse fixture: disables env_file, clears leaked env
  vars from Settings fields and Click CLI envvars
- Patch time.sleep in 3 subscriber scheduler tests (~3s -> ~0.03s)
- Fix pytest.raises(Exception, match='') warning -> IntegrityError
- Add .venv activation to .envrc
- Suppress warn_unused_ignores for tests in mypy config (single-file
  pre-commit checks lack full-project context)
This commit is contained in:
Louis King
2026-06-14 22:03:30 +01:00
parent 6c85ea04c0
commit 96a78d79f6
8 changed files with 231 additions and 109 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import hashlib
import pytest
from pydantic import ValidationError
from sqlalchemy import create_engine
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import sessionmaker
from meshcore_hub.common.models import Base, Channel, ChannelVisibility
@@ -118,7 +119,7 @@ class TestChannelModel:
db_session.commit()
db_session.add(ch2)
with pytest.raises(Exception, match=""):
with pytest.raises(IntegrityError):
db_session.commit()
def test_channel_default_values(self, db_session) -> None: