skillfed

pact-python

Tool for creating and verifying consumer-driven contracts using the Pact framework.

pact-python v3.4.0 1.6M downloads/30d#3,728 on PyPI677
Permissive license MIT License Copyright (c) 2017 Pact Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) Active released

What it is and what it does

Pact Python is a consumer-driven contract testing framework that replaces expensive end-to-end integration tests with fast, reliable unit tests. Instead of spinning up full test environments and coordinating multiple services, you define contracts that specify what a client expects from a server and what a server will provide—then verify both sides independently against that contract. This catches breaking changes early and lets you test locally without complex fixtures or test environments.

The package wraps the Pact framework (which supports 12+ languages) and provides a configurable mock server, powerful matching rules to prevent brittle assertions, and integration with Pact Broker or PactFlow for CI/CD workflows. It supports HTTP/REST and event-driven systems, runs on Python 3.10 and later across macOS, Windows, and Linux, and collects optional anonymous telemetry (disableable via PACT_DO_NOT_TRACK=1).

Use it for:

  • Test microservice interactions locally without spinning up dependent services or complex test environments
  • Verify that API clients and servers remain compatible before deploying, catching breaking changes early
  • Document API contracts automatically and share them across teams via Pact Broker or PactFlow
  • Replace brittle end-to-end integration tests with fast, deterministic unit tests that run in CI/CD
  • Test event-driven systems by defining and verifying message contracts between producers and consumers

Worth the install?

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

Pact Python implements consumer-driven contract testing for APIs and microservices, letting you write fast unit tests that verify both client and server expectations against a shared contract instead of running brittle end-to-end integration tests.

Yes. Pact Python is actively maintained, production-stable (Development Status 5), has no known vulnerabilities, low install friction, and solves a real problem—replacing expensive integration tests with reliable contract tests. The MIT license is permissive. Install it if you're testing APIs or microservices and want to shift testing left and reduce test environment complexity.

Install

pact-python on PyPI

pip

pip install pact-python

uv

uv add pact-python

poetry

poetry add pact-python

Installing pact-python

Before you install

Low friction installation with three runtime dependencies. Actively maintained with recent releases; last commit 2026-08-13 and 677 repository stars indicate ongoing development and community use.

License in practice

MIT License permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal restrictions—only requiring preservation of copyright and license notices.

Quickstart

pip install pact-python

from pact import Consumer, Provider

consumer = Consumer('MyConsumer')
provider = Provider('MyProvider')

# Define contract expectations and verify interactions

Requires Python 3.10 or later; pact-python-ffi dependency may require a compatible FFI runtime on your system.

Verify before relying

  • Specific HTTP/REST and event-driven system capabilities and their scope of support
  • Details on the configurable mock server's feature set and configuration options
  • How the matching rules system works and what types of brittle test scenarios it prevents
  • Integration workflow details with Pact Broker / PactFlow for CI/CD
  • Whether telemetry can be fully disabled and what data collection occurs by default

Package facts

License MIT License Copyright (c) 2017 Pact Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 3 — pact-python-ffi, typing-extensions, yarl
Maintenance actively maintained — 102 days since the last release
Last repo commit
First released
Downloads 1,600,435/month — #3,728 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pact_python-3.4.0-py3-none-any.whl

Keywords: contract-testing, pact, testing

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Testing

Tags

contract testing frameworkAPI integration testingconsumer-driven contractsmicroservice testingmock server testingpact testingAPI contract verification
contract-testingmicroservicesapi-testing

More Testing packages