pytest-unordered
Test equality of unordered collections in pytest
What it is and what it does
pytest-unordered is a pytest plugin that adds an `unordered()` wrapper function for assertions that compare collection contents while ignoring element order. It solves the common testing problem where APIs return data structures (lists, tuples, nested objects) in unpredictable or arbitrary order, making naive equality assertions fragile and test code verbose.
The package shines when testing complex nested data structures: you can wrap only the parts where order doesn't matter, leaving other parts under strict order checking. It handles dictionaries, lists, tuples, and generators, and supports both container-type-strict and container-type-agnostic comparison modes. The single runtime dependency is pytest itself, making installation and integration straightforward.
Use it for:
- Test REST API responses that return lists of objects in unpredictable order without writing custom comparison logic.
- Assert nested data structures (e.g., customer records with order lists) where only some levels should ignore order.
- Compare collections of dictionaries or other unhashable types where set() or sorted() approaches fail.
- Verify database query results or GraphQL responses that don't guarantee result ordering.
- Write readable, maintainable assertions for complex JSON payloads in integration tests.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a pytest assertion helper to compare collections by content rather than order, useful for testing APIs that return data in arbitrary sequences.
Yes. This is a focused, well-maintained tool that solves a real testing pain point with minimal friction. No security issues, permissive license, active development, and low dependency overhead make it a safe addition to any pytest-based test suite.
Install
pytest-unordered on PyPI
pip
pip install pytest-unordereduv
uv add pytest-unorderedpoetry
poetry add pytest-unorderedInstalling pytest-unordered
Before you install
Low friction: pure Python wheel with only pytest as a runtime dependency. Actively maintained with recent releases; last commit 2026-06-16.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in your own projects.
Quickstart
pip install pytest-unordered
from pytest_unordered import unordered
assert [1, 20, 300] == unordered([20, 300, 1])
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pytest |
| Maintenance | actively maintained — 59 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 10,998,579/month — #1,421 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_unordered-0.8.0-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
re-assertProvides a helper class for regex assertions…
permissive · top 15,000 on PyPI
dirty-equalsProvides custom equality matchers that make…
permissive · top 5,000 on PyPI
anysProvides matcher objects that compare equal to…
permissive · top 5,000 on PyPI
pytest-instaA pytest plugin that enables snapshot testing…
unclear · top 15,000 on PyPI
pytest-assumeA pytest plugin that collects and reports…
permissive · top 15,000 on PyPI
assertsProvides stand-alone assertion functions for…
unclear · top 15,000 on PyPI
pytest-deepassertA pytest plugin that replaces standard…
permissive · top 15,000 on PyPI
pytest-checkA pytest plugin that allows tests to continue…
unclear · top 5,000 on PyPI
pyspark-testProvides a testing utility to assert equality…
permissive · top 15,000 on PyPI
pytest-schemaValidates function return values and API…
permissive · top 15,000 on PyPI