API¶
pico_testing.plugin ¶
Pytest plugin: isolated pico containers by default.
Installed as a pytest11 entry point — active in any venv that has pico-testing, no conftest wiring needed.
pico_isolation(request, monkeypatch) ¶
Tests must not depend on which pico plugins happen to be installed in the venv — auto-discovery is opt-in via the pico_auto_plugins marker.
Source code in src/pico_testing/plugin.py
make_container(request) ¶
Factory for pico containers with automatic shutdown on teardown.
The pico_module ini option (usually the package under test) is prepended to the modules list, so make_container() boots it alone.
Usage::
def test_service(make_container):
container = make_container("my_pkg", config={"my": {"key": "value"}})
svc = container.get(MyService)
Source code in src/pico_testing/plugin.py
make_client() ¶
FastAPI TestClient over a container's app; lifespan runs, closed on teardown.
The client exit triggers the pico-fastapi lifespan shutdown AND the container fixture shuts down again: requires pico-ioc >= 2.3.3 (idempotent shutdown).
Usage::
def test_endpoint(make_container, make_client):
container = make_container("pico_fastapi", config={"fastapi": {"title": "t"}})
client = make_client(container)
assert client.get("/api/ping").status_code == 200