expects
Expressive and extensible TDD/BDD assertion library for Python
What it is and what it does
Expects is a TDD/BDD assertion library that provides a fluent, composable syntax for writing test expectations. Instead of traditional assert statements, you use an `expect()` function paired with matchers (like `be_empty`, `equal`, `have_key`) chained with `.to()` or `.not_to()` to express what you expect from your code. The library supports combining matchers with `&` (and) and `|` (or) operators, and you can define custom matchers to extend its behavior.
The package has no runtime dependencies, making it lightweight to install. However, it is dormant—the last release was 2018-10-25, and it carries classifiers for Python 2.7, 3.5, 3.6, and 3.7, which are all end-of-life. No updates or security patches have been released in 2850 days, so using it on modern Python versions is risky and unsupported.
Use it for:
- Writing readable BDD-style test assertions in test suites where fluent syntax improves clarity over raw assert statements.
- Defining custom matchers for domain-specific test assertions that are reusable across a test suite.
- Testing exception behavior with matchers like `raise_error` to verify that code fails as expected.
- Composing complex assertions on data structures (dicts, lists) using chainable matchers and logical operators.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Expects is an assertion library for TDD/BDD that lets you write test expectations using a fluent, composable matcher syntax with support for custom matchers.
No. The package is dormant (last release 2018-10-25) and targets end-of-life Python versions (2.7, 3.5, 3.6, 3.7). Compatibility with later Python versions is unverified and likely broken. For modern TDD/BDD assertion libraries, consider actively maintained alternatives.
Install
expects on PyPI
pip
pip install expectsuv
uv add expectspoetry
poetry add expectsInstalling expects
Before you install
Installation friction is high—the package is dormant (last release 2018-10-25, no updates in 2850 days) and carries classifiers for Python 2.7, 3.5, 3.6, and 3.7, making it a poor fit for modern Python environments. The repo is not archived but shows no active maintenance.
License in practice
Licensed under Apache 2.0 (permissive), so you can use it freely in commercial and open-source projects without restriction, though the dormant status means no legal updates or security patches are forthcoming.
Quickstart
pip install expects
from expects import expect, be_empty, equal
expect([]).to(be_empty)
expect('Foo').to(equal('Foo'))
The package targets Python 2.7, 3.5, 3.6, and 3.7; compatibility with later Python versions is unverified.
Verify before relying
- Whether the package actually works on Python versions released after 3.7.
- Whether custom matchers can be defined and composed as the description suggests in practice.
- Current test coverage and whether the built-in matchers cover common assertion patterns.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | dormant — 2,850 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 208,846/month — #9,524 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: expects-0.9.0.tar.gz
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
surerSurer provides fluent, RSpec-inspired assertion…
permissive · top 15,000 on PyPI
suresure provides fluent, chainable assertion…
copyleft · top 15,000 on PyPI
ensureensure provides literate assertion helpers for…
permissive · top 5,000 on PyPI
assertpyProvides a fluent assertion API for writing…
permissive · top 5,000 on PyPI
great-expectationsDefines and validates data quality…
permissive · top 1,000 on PyPI
great-expectations-experimentalExperimental extensions and early-stage…
permissive · top 15,000 on PyPI
busypieProvides expressive, fluent API for…
permissive · top 15,000 on PyPI
spark-expectationsSpark Expectations is a data quality framework…
unclear · top 15,000 on PyPI
TestSlideTestSlide is a test framework for Python that…
permissive · top 15,000 on PyPI
delayed-assertCollects multiple assertion failures in a test…
unclear · top 15,000 on PyPI