Fluent, chainable assertions for Python tests — HTTP, architecture, and database. Inspired by Laravel's elegant testing API.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyssertive-0.10.1.tar.gz.
File metadata
- Download URL: pyssertive-0.10.1.tar.gz
- Upload date:
- Size: 85.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0205a4ba29b973f14af96da72cc8e2c980335d9cc05538dd53c5ee0d461cdf60
|
|
| MD5 |
481414dd9a213a291b5f97a8e09b45ed
|
|
| BLAKE2b-256 |
f01b894bebab12b3cd4ed3b7dd52951ab5c231fd0b6778f9b5db4eac378beace
|
Provenance
The following attestation bundles were made for pyssertive-0.10.1.tar.gz:
Publisher:
release.yml on othercodes/pyssertive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyssertive-0.10.1.tar.gz -
Subject digest:
0205a4ba29b973f14af96da72cc8e2c980335d9cc05538dd53c5ee0d461cdf60 - Sigstore transparency entry: 1754409107
- Sigstore integration time:
-
Permalink:
othercodes/pyssertive@0457f96edb563476ab4ec4f807b38edd09136a24 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/othercodes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0457f96edb563476ab4ec4f807b38edd09136a24 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyssertive-0.10.1-py3-none-any.whl.
File metadata
- Download URL: pyssertive-0.10.1-py3-none-any.whl
- Upload date:
- Size: 45.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c91be562faa67476b7df7ce8e95b0691f287879e034ec8cde9d229c14733f15a
|
|
| MD5 |
991a6bef5db38fec8af7226b9a836bb2
|
|
| BLAKE2b-256 |
63665ab017588968486944cd51ef10f8635bc5edcb4ceadb39a25c76fad855f4
|
Provenance
The following attestation bundles were made for pyssertive-0.10.1-py3-none-any.whl:
Publisher:
release.yml on othercodes/pyssertive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyssertive-0.10.1-py3-none-any.whl -
Subject digest:
c91be562faa67476b7df7ce8e95b0691f287879e034ec8cde9d229c14733f15a - Sigstore transparency entry: 1754409129
- Sigstore integration time:
-
Permalink:
othercodes/pyssertive@0457f96edb563476ab4ec4f807b38edd09136a24 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/othercodes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0457f96edb563476ab4ec4f807b38edd09136a24 -
Trigger Event:
push
-
Statement type: