skillfed

tavern

Simple testing of RESTful APIs

tavern v3.6.1 267.1K downloads/30d#8,297 on PyPI1,153
Permissive license Active released

What it is and what it does

Tavern lets you write API tests in plain YAML files that pytest can discover and run alongside your other tests. Instead of writing Python code for each API call and assertion, you declare the request (URL, method, headers, body) and the expected response (status code, JSON structure) in a readable, version-controllable format. It integrates directly with pytest, so you get all of pytest's reporting, plugins, and CI/CD tooling for free.

The package supports testing REST APIs, MQTT message brokers, and gRPC services in the same test file. You can use pytest fixtures and hooks to extend tests, write custom validation functions in Python when YAML isn't expressive enough, and organize tests with pytest marks. It ships as a pytest plugin (auto-discovered on install), a standalone command-line tool (tavern-ci) for shell scripts, and a Python library for programmatic use.

Use it for:

  • Write and maintain API contract tests in version control as YAML files that non-developers can read and modify.
  • Run API tests in CI/CD pipelines against staging or test servers, integrated with pytest's reporting and failure notifications.
  • Test MQTT brokers and gRPC services alongside REST APIs in a single test suite without switching frameworks.
  • Validate JSON response structure and values using jmespath and jsonschema without writing custom Python assertions.
  • Extend tests with Python fixtures and custom validation functions for complex scenarios while keeping simple tests declarative.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Tavern is a pytest plugin and command-line tool for automated testing of RESTful APIs, MQTT-based APIs, and gRPC services using a YAML-based test syntax.

Yes. Tavern is actively maintained, has no known vulnerabilities, and solves a real problem—making API tests readable and maintainable. The YAML syntax is genuinely easier to write and review than Python test code for straightforward cases, and the pytest integration means you don't sacrifice tooling or ecosystem. Low install friction and permissive licensing add no friction. Best for teams that value test readability and want to keep API tests in version control as documentation.

Install

tavern on PyPI

pip

pip install tavern

uv

uv add tavern

poetry

poetry add tavern

Installing tavern

Before you install

Low install friction with a pure-Python wheel distribution. Active maintenance with a recent release (61 days ago) and ongoing commits. Depends on 10 runtime packages including pytest, requests, and validation libraries—all standard, well-maintained tools.

License in practice

Permissive license (MIT) means you can use, modify, and distribute Tavern freely in commercial and private projects without restriction.

Quickstart

pip install tavern[pytest]

# Create test_api.tavern.yaml:
# ---
# test_name: Test API endpoint
# stages:
#   - name: GET request
#     request:
#       url: https://api.example.com/data
#       method: GET
#     response:
#       status_code: 200

pytest test_api.tavern.yaml -v

Requires Python 3.11 or later. Best used with pytest; standalone CLI tool tavern-ci available but pytest integration is the recommended path.

Verify before relying

  • Whether the 10 runtime dependencies are all required for basic use or if some are optional for specific features.
  • Performance characteristics when testing high-volume or long-running API test suites.
  • Extent of custom Python validation function support and how it compares to other frameworks.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 10 — PyYAML, jmespath, jsonschema, pyjwt, pykwalify, pytest, python-box, requests, simpleeval, stevedore
Maintenance actively maintained — 61 days since the last release
Last repo commit
First released
Downloads 267,069/month — #8,297 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: tavern-3.6.1-py3-none-any.whl

Keywords: testing, pytest

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development :: TestingTopic :: Utilities

Tags

api testing yamlpytest api automationrest api test frameworkmqtt api testinggrpc service testingdeclarative api testsapi contract testing
api-testingpytest-pluginyaml-driven

More Utilities packages