← Back to all products
$10
API Test Framework
Fluent API testing with chainable assertions, performance benchmarks, and HTML reports.
PythonMarkdown
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 9 files
api-test-framework/
├── LICENSE
├── README.md
├── examples/
│ └── test_suite.example.py
├── free-sample.zip
├── guide/
│ ├── 01_api-test-framework.md
│ ├── 02_features.md
│ └── 03_quick-start.md
├── index.html
└── src/
└── main.py
📖 Documentation Preview README excerpt
API Test Framework
Fluent API testing with chainable assertions, performance benchmarks, and HTML reports. Zero dependencies.
Part of the API Launchpad toolkit by [CodeVault](https://codevault.dev).
Features
- Fluent request builder:
.get("/users").header("Auth", "Bearer tk").expect_status(200).run() - Chainable assertions: status codes, headers, JSON paths, body content, response time
- Test suite runner with setup/teardown hooks
- Performance benchmarking: p50, p95, p99 latency and requests/second
- HTML report generation with pass/fail summary and timing data
- JSON path extraction:
$.users[0].name— navigate nested response bodies - Zero dependencies — runs on Python stdlib only
Quick Start
# Run demo tests against a local server
python3 src/main.py --demo --base-url http://localhost:8000
# Benchmark an endpoint
python3 src/main.py --benchmark http://localhost:8000/users --iterations 50
# Generate an HTML report
python3 src/main.py --demo --base-url http://localhost:8000 --report report.html
Writing Tests
from main import RequestBuilder, TestSuite
suite = TestSuite("My API Tests", base_url="http://localhost:8000")
@suite.test
def test_list_users():
return (RequestBuilder()
.get("/users")
.expect_status(200)
.expect_header_exists("content-type")
.expect_json_path("$.count", lambda v: v is not None)
.expect_max_time(500)
.named("List Users"))
@suite.test
def test_create_user():
return (RequestBuilder()
.post("/users")
.json_body({"name": "Test User", "email": "test@example.com"})
.expect_status(201)
.expect_json_path("$.name", lambda v: v == "Test User")
.named("Create User"))
@suite.test
def test_not_found():
return (RequestBuilder()
.get("/users/99999")
.expect_status(404)
*... continues with setup instructions, usage examples, and more.*
📄 Code Sample .py preview
src/main.py
#!/usr/bin/env python3
"""
API Test Framework — Fluent API Testing with Assertions & Benchmarks
======================================================================
A lightweight API testing framework with a fluent request builder,
chainable assertions, test suite runner, performance benchmarking,
and HTML report generation.
Zero dependencies. Import or run as CLI.
Part of the API Launchpad toolkit by DataNest.
License: MIT
"""
from __future__ import annotations
import json
import logging
import statistics
import time
import traceback
import urllib.request
import urllib.error
from dataclasses import dataclass, field
from datetime import datetime, timezone
from html import escape
from pathlib import Path
from typing import Any, Callable
from urllib.parse import urlencode
# ---------------------------------------------------------------------------
# Configuration
# ---------------------------------------------------------------------------
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S",
)
logger = logging.getLogger("api-test")
# ---------------------------------------------------------------------------
# HTTP Client — Minimal wrapper around urllib
# ---------------------------------------------------------------------------
@dataclass
class HTTPResponse:
"""Parsed HTTP response for assertion chaining."""
# ... 593 more lines ...