Skip to main content

Fluent HTTP API testing library with Pydantic model binding

Project description

basst

Pydantic-first HTTP testing client for Python. Fluent request builder, one-step model binding, native Python assertions.

Install

pip install basst

Quick Start

from basst import Client, matchers
from pydantic import BaseModel


class User(BaseModel):
    id: int
    name: str
    email: str
    roles: list[str]


api = Client("https://api.example.com")

user = (
    api.get("/users/1")
    .header("X-Token", "secret")
    .expect()
    .status(200)
    .header("content-type", matchers.contains("json"))
    .model(User)
)

assert user.name == "Ada"
assert "admin" in user.roles

Features

  • Fluent, chainable request builder (all HTTP verbs)
  • Pydantic model binding with .model() and .model_list()
  • Automatic content-type validation before parsing
  • Built-in header matchers (equals, contains, starts_with, ends_with, matches)
  • Custom matchers via simple callables
  • Async support (await only at .expect())
  • Contextual error messages with request/response details
  • from_httpx for wrapping existing httpx clients

Documentation

Full documentation at basst.readthedocs.io.

Inspiration

basst draws inspiration from REST Assured (Java) and gavv/httpexpect (Go).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

basst-0.1.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basst-0.1.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file basst-0.1.1.tar.gz.

File metadata

  • Download URL: basst-0.1.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for basst-0.1.1.tar.gz
Algorithm Hash digest
SHA256 63423774fe6a1d3b6d61e8ff80a5ea759030e7a01d89b0b88c88e7464a00dfbe
MD5 018db707b0d11d292ecf0a4380cba89a
BLAKE2b-256 4c4d55be60b7d12894954e10c0ddc8b97a9a0f53bf584a24326cba77363b586f

See more details on using hashes here.

File details

Details for the file basst-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: basst-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for basst-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d2a4154ea043a15a052e6b6e025cf8bbd681260a28f4d71a71a04b00c97d7da
MD5 c4f0359ab0880b63e1e8fbfe37e371a1
BLAKE2b-256 37c4546286cccca489a4f1a743124f0057a7101d955b0261f5659fde67f83449

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page