CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/pytest-api-testing

Pytest patterns for Python APIs -- httpx AsyncClient, conftest fixtures, database isolation, parametrize edge cases, error response testing, auth flows, factory fixtures

99

1.23x
Quality

99%

Does it follow best practices?

Impact

100%

1.23x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

Evaluation results

100%

Set Up a Test Suite for a Product Catalog API

FastAPI test client setup

Criteria
Without context
With context

Uses AsyncClient

100%

100%

Uses ASGITransport

100%

100%

asyncio_mode auto

100%

100%

pytest-asyncio installed

100%

100%

httpx installed

100%

100%

Fixture in conftest.py

100%

100%

Function-scoped client

100%

100%

base_url set

100%

100%

No requests/urllib import

100%

100%

100%

17%

Add Integration Tests for a Task Management API with Database

Database fixture isolation

Criteria
Without context
With context

Session-scoped engine

100%

100%

Function-scoped session

100%

100%

Cleanup before yield

100%

100%

autouse cleanup

0%

100%

Dependency override

100%

100%

No database mock

100%

100%

Override cleared after

100%

100%

in-memory or transaction isolation

80%

100%

Fixtures in conftest

100%

100%

100%

49%

Test Input Validation and Duplicate Handling for a Membership Registration API

Factory fixtures and parametrize

Criteria
Without context
With context

Factory fixture defined

0%

100%

Factory accepts overrides

0%

100%

Factory used with variations

0%

100%

parametrize for validation

100%

100%

parametrize covers 3+ cases

100%

100%

No hardcoded duplicate data

60%

100%

Error body asserted

0%

100%

Duplicate email test

100%

100%

Fixtures in conftest

100%

100%

100%

4%

Write Comprehensive Tests for a User Account API

Error response and schema testing

Criteria
Without context
With context

404 body asserted

100%

100%

422 body asserted

50%

100%

409 tested

100%

100%

404 on delete

100%

100%

List response structure

100%

100%

Individual item structure

100%

100%

Password not exposed

100%

100%

Password hash not exposed

100%

100%

Invalid JSON tested

100%

100%

Error response is JSON

100%

100%

Multiple error types covered

100%

100%

100%

25%

Test Authentication and External Service Resilience for a Notification API

Auth flows and monkeypatch

Criteria
Without context
With context

No-token test

100%

100%

Invalid token test

100%

100%

Valid token grants access

100%

100%

auth_headers fixture

100%

100%

auth_headers in conftest

100%

100%

monkeypatch for SMTP failure

0%

100%

No unittest.mock for simple patch

0%

100%

503 on service failure

100%

100%

Login flow in fixture

100%

100%

asyncio_mode config

100%

100%

Evaluated
Agent
Claude Code
Model
Claude Sonnet 4.6

Table of Contents