Shared pytest fixtures and helpers for writing tests against simple_module apps and modules.
Fixtures are exposed via a pytest11 entry point, so installing the package is enough — no conftest.py import needed.
pip install simple_module_test
# or, if you already pulled in the framework:
pip install "simple_module_hosting[dev]"All fixtures below are auto-registered via the pytest11 entry point — installing the package is enough.
fake_event_bus— a fresh recordingEventBusper test that captures everypublish/publish_nowaitcall.build_test_app— callable returning a minimal FastAPI app that loads exactly one module.settings— a ready-to-useSettingsinstance with an in-memory SQLite database and multi-tenancy enabled.db_state,engine,db_session— freshDatabaseStateper test;db_sessionalso creates all module tables and stampsalembic_versionat head so the boot-time migration check passes.app— acreate_app(settings)instance withlifespanstarted and stopped.client— anhttpx.AsyncClientbound to the test app.authenticated_client— same but with an admin user seeded and a forged session cookie attached. Requires theusersmodule to be installed (it seeds the admin viausers.bootstrap); apps scaffolded bysmpyinclude it.
In a module's tests/test_something.py:
import pytest
pytestmark = pytest.mark.asyncio
async def test_create_order(authenticated_client):
resp = await authenticated_client.post(
"/api/orders",
json={"customer_id": 1, "total_cents": 9900},
)
assert resp.status_code == 201
assert resp.json()["total_cents"] == 9900No fixture imports, no conftest.py — the pytest11 entry point auto-loads them.
simple_module_core,simple_module_db,simple_module_hostingpytest,pytest-asyncio,httpx,sqlalchemy
MIT — see LICENSE.