- Boolean quantity boundary
- Replay assertions
Test subject.unique_ids(ids): keep the first appearance of every ID in input order. An empty string is a valid ID. Use subject.NAME in a repeated input and cover an empty list.
- Yield fixture cleanup
Use a yield fixture for subject.Resource. A new resource must be open; close() must mark it closed, including when work raises. Test cleanup through try/finally and keep the fixture finalizer safe for an already closed resource.
- Dependent fixtures
Build fixtures for a seed ID list and its repository. Test subject.Repository(seed): copy the seed, append new IDs in order, and keep caller-owned seed data unchanged. Two repositories created from the same seed must be independent.
- Status transition table
Parametrize the status policy in subject.can_close(status). Only open and assigned may close. Reject closed, an empty string, and mixed-case Open; this contract uses exact tokens.
- Readable parameter IDs
Use named pytest.param(..., id=...) cases for subject.normalize_id(text). Strip outer whitespace and uppercase letters; keep internal spaces and preserve an empty result. Include subject.NAME.
- Injected clock patches
Patch the clock where subject.expired(deadline) looks it up. A deadline is expired when subject.clock() is greater than or equal to it. Assert before, exactly at, and after a deadline based on subject.VALUE.
- Async mock dependency
Test async subject.lookup(fetch, record_id) with AsyncMock. Return the awaited dependency value, pass the original ID, and propagate LookupError. Use subject.NAME; no network request is needed.
- ASGI validation errors
Test POST /repairs on subject.app. Its Pydantic body has units: int constrained to greater than zero. A positive value returns that value with status 201; zero and a missing field return 422.
- Explicit lifespan tests
Test application startup and shutdown explicitly with subject.app.router.lifespan_context. During lifespan, GET /ready must return {"ready": true}. After exit, subject.app.state.ready must be false. ASGITransport does not start lifespan for you.
- Optional dependency groups
Test subject.test_requirements(text) on a pyproject TOML string. Return only [project.optional-dependencies].test, preserving order and duplicates. Return an empty list if the optional group is absent.
- Explicit public exports
Test subject.public_names(namespace). If __all__ exists, return its list exactly, including an empty list. Otherwise return sorted names that do not start with an underscore. Use subject.NAME in a supplied namespace.