ensure
Literate BDD assertions in Python with no magic
Decision gist · record as of 2026-08-14
Yes, if you want readable assertions in tests or production validation. The library is stable, has no known vulnerabilities, and adds minimal install friction. The dormant maintenance (no updates since late 2023) is a minor concern but not a blocker—the API is mature and the codebase is simple. Suitable for projects prioritizing readable validation code over framework integration.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.6 or later; function annotation enforcement via @ensure_annotations decorator requires Python 3.
- Low friction install with a single lightweight dependency (six).
- Dormant maintenance status since late 2023, though the repository remains active and the package is marked Production/Stable.
License · maintenance · safety
Apache Software License (permissive) — Licensed under Apache Software License (permissive), allowing use in commercial and proprietary projects with minimal restrictions.
last release 2023-12-10 (978 days) · last repo commit 2024-12-03 · 157 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 863,431 downloads/mo, #4,868 on PyPI
Alternatives
Verify before relying
pip install ensure
from ensure import ensure
ensure(1).is_an(int)
ensure({1: 2}).has_key(1).whose_value.equals(2)
ensure([1, 2, 3]).is_sorted()- Whether dormant maintenance status affects real-world reliability or compatibility with current Python versions beyond 3.11.
- Performance characteristics compared to other assertion libraries in production validation scenarios.
What it is and what it does
ensure is a standalone assertion library that lets you write validation checks using a fluent, readable API inspired by JavaScript testing frameworks. Instead of cryptic assert statements or unittest methods, you chain readable clauses like `.is_an(int)`, `.contains()`, and `.has_key()` to express what you expect. The library raises informative EnsureError exceptions with clear messages when checks fail, making it useful for both test code and production validation (e.g., API input checking).
The package depends only on six and installs as a pure Python wheel. It supports Python 3.6 through 3.11 and includes a decorator, @ensure_annotations, for enforcing function signature type hints at runtime. Because ensure doesn't use the assert statement (which can be disabled with Python's -O flag), validations remain active in optimized production deployments.
Use it for
- Validate API request parameters with readable error messages for client feedback.
- Write BDD-style test assertions that read like English sentences.
- Enforce function argument types at runtime using @ensure_annotations decorator.
- Chain multiple conditions on complex data structures (dicts, lists, sets) with fluent syntax.
- Validate data structure shape and contents in production code without test framework overhead.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you want readable assertions in tests or production validation.
The library is stable, has no known vulnerabilities, and adds minimal install friction. The dormant maintenance (no updates since late 2023) is a minor concern but not a blocker—the API is mature and the codebase is simple. Suitable for projects prioritizing readable validation code over framework integration.
Install
ensure on PyPI
Before you install
Low friction install with a single lightweight dependency (six). Dormant maintenance status since late 2023, though the repository remains active and the package is marked Production/Stable.
Requires Python 3.6 or later; function annotation enforcement via @ensure_annotations decorator requires Python 3.
License in practice
Licensed under Apache Software License (permissive), allowing use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install ensure
from ensure import ensure
ensure(1).is_an(int)
ensure({1: 2}).has_key(1).whose_value.equals(2)
ensure([1, 2, 3]).is_sorted()
Verify before relying
- Whether dormant maintenance status affects real-world reliability or compatibility with current Python versions beyond 3.11.
- Performance characteristics compared to other assertion libraries in production validation scenarios.
Package facts
| License | Apache Software License permissive |
| Python support | Supports the current Python release >=3.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagesix |
| Maintenance | Dormant 978 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 863,431 / month, #4,868 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOS :: MacOS XOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules |
Evidence: ensure-1.0.4-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “literate bdd assertions”
- ensureensure provides literate assertion helpers for validating conditions…
- expectsExpects is an assertion library for TDD/BDD that lets you write test…
- pytest-bddpytest-bdd implements Gherkin-based behavior-driven development…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also sure · assertpy · expects · surer · asserts · re-assert · robotframework-assertion-engine · pytest-assume · delayed-assert · PyHamcrest