A convention-based YAML API testing library for Python & FastAPI
Project description
Autumn-Py - Convention-Based YAML API Testing Framework for Python & FastAPI
Autumn-Py is a convention-based API automation testing framework designed to streamline and simplify the testing process, inspired by the Java Autumn library.
By integrating directly with pytest, Autumn-Py allows you to run clutter-free API tests based on YAML files, eliminating repetitive test code. It supports testing local FastAPI applications (using httpx.Client(app=...) under the hood) as well as external REST services.
Features
- No Boilerplate Code Required: Write tests in YAML, not Python.
- Convention-Based: Follows standard patterns, zero configuration to start.
- pytest Integration: Discovered and run automatically by
pytest. - FastAPI / Local Testing: Route requests directly against your FastAPI app via the
autumn_appfixture. - Arrange-Act-Assert Support: Set up preconditions, run the main API call, and assert expectations.
- Rich Data Generation: Dynamic random names, emails, UUIDs, datetimes, sentences, and more using
faker. - Placeholder Chaining: Reference responses of previous arrange steps in URLs, headers, and request bodies.
- Flexible JSON Assertions: Easily match dynamic fields with matchers (e.g. UUID, datetime, regex, types) and ignore extra fields if needed.
- Conditional Skip Scheduling: Restrict test execution by day or time of day.
Installation
pip install autumn-yaml-test
Quick Start
- Define your test yml files (e.g. under
tests/):
# tests/get_user.yml
name: Get User by ID
act:
url: "https://jsonplaceholder.typicode.com/users/1"
method: GET
asserts:
status: 200
body:
id: 1
name: "Leanne Graham"
email: "${json-unit.matches:regex}[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"
- Run your tests:
pytest
That's it! The plugin discovers all .yml/.yaml files containing an act: block and executes them dynamically.
Testing a Local FastAPI App
To test your local FastAPI application without running a separate server, define an autumn_app fixture in your conftest.py:
# tests/conftest.py
import pytest
from my_app import app
@pytest.fixture
def autumn_app():
return app
With autumn_app defined, Autumn-Py routes all requests in your YAML files directly through FastAPI's TestClient routing.
YAML Specification
Refer to the examples under tests/resources/ for a full showcase of features including:
- Data generation:
${generate:name},${generate:email},${generate:datetime:1minutesAgo},${generate:uuid}. - Arrange steps: wait steps (
type: wait), API dependencies (type: api), andsaveResponseAs. - Flexible asserts: ignore extra fields using
customization.
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 autumn_yaml_test-1.0.0.tar.gz.
File metadata
- Download URL: autumn_yaml_test-1.0.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d070dc22f2655aa7d417102f996f8aba0f44ab476e65682cf4ba54b9de7b340
|
|
| MD5 |
000c9940bdb4f280199f56e854371831
|
|
| BLAKE2b-256 |
2efb4fb0b3ff574dd790820405e745a9fcb0bd03108365f1b25d638551597182
|
File details
Details for the file autumn_yaml_test-1.0.0-py3-none-any.whl.
File metadata
- Download URL: autumn_yaml_test-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf1f55529fc59323453e5339228c13daa5d0ba6d8b335af6d9d02578e66641a1
|
|
| MD5 |
e819819d7d9723a00198b3b9193bc477
|
|
| BLAKE2b-256 |
f5e864c7e1c22f232abcb6c0ac1ad375a72a78f4fb87cc896c5718de02a31b00
|