Testing

Run integration tests against a real Pounce server

Pounce ships a testing helper that starts a real server in a background thread. Use it when your test needs socket-level behavior instead of direct ASGI calls.

Context Manager

from pounce.testing import TestServer


async def app(scope, receive, send):
    await send({"type": "http.response.start", "status": 200, "headers": []})
    await send({"type": "http.response.body", "body": b"ok"})


def test_app():
    with TestServer(app) as server:
        assert server.url.startswith("http://")

Pytest Fixture

Installingbengal-pounce registers the pounce_serverpytest fixture through the package entry point.

def test_with_fixture(pounce_server):
    with pounce_server(app) as server:
        assert server.is_running

The helper uses Pounce's normal listener, worker, lifespan, and shutdown paths, so it catches integration bugs that a direct ASGI harness would miss.