Testing

A real client, no server — drives your app through WSGI directly.

class=kw>from larz.testing class=kw>import Client
c = Client(app)

assert c.get("/").status == 200
assert "Welcome" in c.get("/").text
assert c.get("/api/me").json["email"] == "a@b.com"

State persists across calls

The client keeps a cookie jar, so login and session state carry between requests, just like a browser.

c.post("/signup", form={"email": "a@b.com", "password": "pw123456"})
r = c.get("/dashboard")              class=com># sent with the session cookie
assert r.status == 200

class=com># redirects are returned, not followed, unless you ask:
assert c.get("/go").redirect == "/"
assert c.get("/go", follow=True).status == 200

Uploads & JSON

post(path, json={...}) sends a JSON body; post(path, body=..., content_type= "multipart/form-data; boundary=...") tests file uploads. TestResponse exposes .status, .text, .json, .redirect and .header(name). There's also c.login(email=, password=).

This is how Larz's own 164-test suite runs — fast, deterministic, no ports.