--- id: anys version: "0.3.1" license: MIT license_treatment: permissive maintenance: active --- # anys — Matchers for pytest License: permissive · Maintenance: active · Downloads: 953.6K/mo ## What it is and what it does anys is a testing utility that provides matcher objects for writing more flexible assertions in unit tests. Instead of comparing exact values, matchers let you assert that a value meets a criterion—such as being a valid ISO 8601 datetime string, falling within a numeric range, matching a regex pattern, or having specific attributes. This is especially useful when testing code that produces values you can't predict in advance (like timestamps or generated IDs) but still need to validate. The package exports pre-built matchers for common types (ANY_INT, ANY_STR, ANY_DATETIME_STR, etc.) and composable matcher classes (AnyGT, AnyMatch, AnyWithAttrs, etc.) that you combine with standard Python equality comparisons. Matchers can be nested in dictionaries, lists, and other structures, and combined using & (both must match) and | (either may match) operators. It has no runtime dependencies and supports Python 3.8 through 3.13 on both CPython and PyPy. Use it for: - Assert that API responses contain valid timestamps or UUIDs without hardcoding exact values. - Validate nested data structures where some fields are dynamic but must meet type or pattern constraints. - Check that function return values fall within expected numeric ranges without manual boundary comparisons. - Test objects with attributes that vary between runs (e.g., creation times) while verifying other fields exactly. - Combine multiple criteria to match complex values—e.g., strings matching a regex AND containing a substring. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides matcher objects that compare equal to values meeting specified criteria, enabling flexible assertions in pytest-style unit tests without manual field-by-field comparison. Yes. This is a lightweight, well-maintained testing utility with no dependencies, permissive licensing, and active development. It solves a real problem in unit testing—validating dynamic or partially-known values—and integrates seamlessly with pytest assertions. The API is straightforward, and the matcher composition model is flexible. Install it if you write tests with pytest and encounter fields you can't assert exactly. ## Install pip install anys uv add anys poetry add anys ## Installing anys Before you install: Low friction installation with no runtime dependencies. Actively maintained with recent commits; last release was 2024-12-01, and the repository shows ongoing activity. License in practice: MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions, making it safe for both open-source and commercial projects. Quickstart: from anys import ANY_DATETIME_STR, AnyGT assert response == { "status": "ok", "timestamp": ANY_DATETIME_STR, "count": AnyGT(0) } Requires Python 3.8 or higher. Verify before relying: - Whether matchers work correctly when nested in custom class instances with non-standard __eq__ implementations. - Performance characteristics when combining many matchers with & and | operators on large data structures. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 953.6K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest assertion matchers, flexible test comparisons, dynamic value matching, unit test helpers, pattern-based assertions, conditional equality checks, test fixture validation, pytest, test-utilities, assertion-helpers [View on SkillFed](https://skillfed.io/packages/anys) · [View on PyPI](https://pypi.org/project/anys/)