pyssertive
Fluent, chainable assertions for everything you test in Python. One vocabulary — from a single value to HTTP responses, JSON, HTML, MCP, and architecture. Inspired by Laravel's elegant testing API.
📚 Documentation
Full documentation lives at othercodes.github.io/pyssertive.
- Installation
- Quickstart
- Guides: Expectations · HTTP · JSON · HTML · Database · Architecture · MCP
- API Reference
Features
- One fluent vocabulary for any value, response, or contract under test
- HTTP status code assertions (2xx, 3xx, 4xx, 5xx)
- JSON response validation with path navigation, fragments, and JSON Schema contract testing
- HTML content assertions with CSS-selector scoping
- Template, context, session, cookie, and header assertions
- Streaming response and file download assertions
- Architecture assertions for import boundaries, layers, and bounded-context isolation
- MCP (Model Context Protocol) assertions with MCP-native vocabulary
- Debug helpers for test development
Requirements
- Python 3.10+
- Django 4.2, 5.2, or 6.0 (optional, only if using the Django adapter)
- httpx 0.27+ (optional, only if using the httpx adapter for FastAPI/Starlette/FastMCP)
Installation
pip install pyssertive # core
pip install pyssertive[django] # with Django adapter
pip install pyssertive[httpx] # with httpx adapter (FastAPI, Starlette, FastMCP)
Quickstart
from pyssertive import expect
# Generic values — one vocabulary for anything
expect(42).equals(42)
expect([1, 2, 3]).has_count(3).contains(2).does_not_contain(99)
expect("alice@example.com").is_instance_of(str).matches(r".+@.+")
# The same expect dispatches to specialized assertables
expect.json(payload).where("status", "active").missing("password")
expect.html(markup).see_text("Welcome back, Alice")
expect.arch("myapp.domain").should_only_depend_on(["stdlib", "myapp.domain"])
HTTP responses chain fluently from a test client:
import pytest
from pyssertive.adapters.django import FluentHttpAssertClient
@pytest.fixture
def client():
from django.test import Client
return FluentHttpAssertClient(Client())
@pytest.mark.django_db
def test_user_api(client):
client.get("/api/users/")\
.assert_ok()\
.assert_json_path("count", 10)\
.assert_header("Content-Type", "application/json")
See the documentation for the full guides and API reference.
License
MIT — see LICENSE.
Metadata
Release files for pyssertive 0.10.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyssertive-0.10.1.tar.gz | 85.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyssertive-0.10.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 130.8 kB
Release files / pyssertive-0.10.1.tar.gz
| Download URL | pyssertive-0.10.1.tar.gz |
|---|---|
| Size | 85.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0205a4ba29b973f14af96da72cc8e2c980335d9cc05538dd53c5ee0d461cdf60
|
|
BLAKE2b-256 checksum How to use checksums |
f01b894bebab12b3cd4ed3b7dd52951ab5c231fd0b6778f9b5db4eac378beace
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.
Transparency logRelease files / pyssertive-0.10.1-py3-none-any.whl
| Download URL | pyssertive-0.10.1-py3-none-any.whl |
|---|---|
| Size | 45.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c91be562faa67476b7df7ce8e95b0691f287879e034ec8cde9d229c14733f15a
|
|
BLAKE2b-256 checksum How to use checksums |
63665ab017588968486944cd51ef10f8635bc5edcb4ceadb39a25c76fad855f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.
Transparency log