Skip to main content

simple_module_test

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.

The plugin ignores the invoking project's .env before collection, while exported environment variables and temporary configuration-test files still work. Test imports default to importlib, allowing repeated basenames. Add support directories to pytest's pythonpath when using plain helper imports or pytest_plugins.

Install

pip install simple_module_test
# or, if you already pulled in the framework:
pip install "simple_module_hosting[dev]"

What it provides

All fixtures below are auto-registered via the pytest11 entry point — installing the package is enough.

  • fake_event_bus — a fresh recording EventBus per test that captures every publish/publish_nowait call.
  • build_test_app — callable returning a minimal FastAPI app that loads exactly one module.
  • settings — a ready-to-use Settings instance with an in-memory SQLite database and multi-tenancy enabled.
  • db_state, engine, db_session — fresh DatabaseState per test; db_session also creates all module tables and stamps alembic_version at head so the boot-time migration check passes.
  • app — a create_app(settings) instance with lifespan started and stopped.
  • client — an httpx.AsyncClient bound to the test app.
  • authenticated_client — same but with an admin user seeded and a forged session cookie attached. Requires the users module to be installed (it seeds the admin via users.core.bootstrap); apps scaffolded by smpy include it.
  • tenant_client — factory: async with tenant_client("member") as (client, tenant_id, user_id) signs in a fresh user who is an owner / admin / member (default owner) of a new tenant — or of tenant_id= when given — with that tenant active. Requires the users and tenants modules.
  • oidc_test_issuer — an in-process OpenID Connect issuer (OidcTestIssuer): an RSA signing key with jwks(), discovery() and sign(claims), for testing an OIDC sign-in through httpx_mock without an IdP.

Usage

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"] == 9900

No fixture imports, no conftest.py — the pytest11 entry point auto-loads them.

To enforce the standard package and test layout, call the public helper from a test:

from pathlib import Path

from simple_module_test import assert_module_layout


def test_orders_layout():
    assert_module_layout(Path("modules/orders"), "orders")

For standalone module projects use Path("."). Pass named domain directories with domain_areas={"fulfillment"} and temporary compatibility files with deprecated_root.

Depends on

  • simple_module_core, simple_module_db, simple_module_hosting
  • pytest, pytest-asyncio, httpx, sqlalchemy

License

MIT — see LICENSE.

Metadata

Release files for simple-module-test 0.0.49

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-module-test 0.0.49
File Size Uploaded Provenance Actions
simple_module_test-0.0.49.tar.gz 42.8 kB With provenance Details for simple_module_test-0.0.49.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simple-module-test 0.0.49
File Interpreter ABI Platform Actions
simple_module_test-0.0.49-py3-none-any.whl Python 3 none any Details for simple_module_test-0.0.49-py3-none-any.whl

Total release size: 81.9 kB

Release files / simple_module_test-0.0.49.tar.gz

Download URL simple_module_test-0.0.49.tar.gz
Size 42.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0b2b24228e3461fb6c2e86ec632ab251fbe880e07ef52630dbb4b6fa7bb193b4
BLAKE2b-256 checksum
How to use checksums
e9e8499a3e9e3b06886a1ca0560765e9f08f6b04ce089243d89efb9ed8e73806
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / simple_module_test-0.0.49-py3-none-any.whl

Download URL simple_module_test-0.0.49-py3-none-any.whl
Size 39.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf51d5cac4dbaa234e2c8b7e25c1db6d7e998598f7d1078eb48ff8feae4634c8
BLAKE2b-256 checksum
How to use checksums
cf1fcaa16ecd6ceea5e55b310ef61696628ad573825d246815ecb0d77e874bd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for simple-module-test 0.0.49

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for simple_module_test-0.0.49.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.49 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page