skillfed

pytest-unordered

Test equality of unordered collections in pytest

pytest-unordered v0.8.0 11.0M downloads/30d#1,421 on PyPI57
Permissive license MIT Active released

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-unordered

uv

uv add pytest-unordered

poetry

poetry add pytest-unordered

Installing 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

Development Status :: 4 - BetaFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: LibrariesTopic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTopic :: UtilitiesTyping :: Typed

Tags

pytest unordered collection comparisontest collection content ignore orderassert lists equal regardless of orderpytest nested unordered assertionsapi response testing unordered datapytest collection equality without order
pytest-plugintest-assertioncollection-comparison

More Libraries packages