--- id: ensure version: "1.0.4" license: Apache Software License license_treatment: permissive maintenance: dormant --- # ensure — Literate BDD assertions in Python with no magic License: permissive · Maintenance: dormant · Downloads: 863.4K/mo ## 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 above — verify before relying. ensure provides literate assertion helpers for validating conditions in Python with readable error messages, usable in both tests and production code without relying on the assert statement. 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 pip install ensure uv add ensure poetry add ensure ## Installing ensure 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. 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() Requires Python 3.6 or later; function annotation enforcement via @ensure_annotations decorator requires Python 3. 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_current - Install friction: low - Maintenance: dormant - Downloads: 863.4K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags readable assertions python, literate bdd assertions, validation helpers python, expressive condition checking, assertion library no magic, runtime type validation, chainable assertions, assertion-library, validation, bdd [View on SkillFed](https://skillfed.io/packages/ensure) · [View on PyPI](https://pypi.org/project/ensure/)