Registry / testing / pytest-unordered

pytest-unordered

JSON →
library0.8.0pypypi✓ verified 27d ago

pytest-unordered is a pytest plugin that provides a specialized `unordered()` matcher for asserting equality of collections (lists, sets, tuples, dictionaries) regardless of element order. It is currently at version 0.7.0 and typically releases new versions to support newer Python versions or add minor features.

pip install pytest-unordered
INSTALL
IMPORT
SIG · PYTEST-UNORDERED
P
pytest-unordered
testingpythonv0.8.0
Install
2.8s avg
Import
427ms
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.444s · 31.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.8s · import 0.410s · 32MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

unordered
from pytest_unordered import unordered
unordered_list
from pytest_unordered import unordered_list
Use for explicit list matching introduced in 0.5.0
unordered_set
from pytest_unordered import unordered_set
Use for explicit set matching introduced in 0.5.0
unordered_dict
from pytest_unordered import unordered_dict
Use for explicit dict matching introduced in 0.5.0

This quickstart demonstrates how to use the `unordered()` matcher within pytest to assert equality of lists and dictionaries where the order of elements or keys does not matter. Save this as a Python file (e.g., `test_order.py`) and run `pytest`.

import pytest from pytest_unordered import unordered def test_list_order_agnostic_equality(): actual_list = [1, 3, 2] expected_list = [2, 1, 3] assert actual_list == unordered(expected_list) def test_dict_order_agnostic_equality(): actual_dict = {'a': 1, 'b': 2} expected_dict = {'b': 2, 'a': 1} assert actual_dict == unordered(expected_dict)
Debug
Known issues
breakingSupport for Python 3.7 was dropped in version 0.6.0. If you are using Python 3.7, you must pin your `pytest-unordered` version.
fix
Upgrade to Python 3.8+ or pin `pytest-unordered<0.6.0` in your `requirements.txt`.
affects: >=0.6.0
breakingThe `unordered` matcher became a factory function in 0.4.0. Prior to this, `unordered` might have been used as a direct collection type (e.g., `UnorderedList`). This change simplifies usage but may break older tests.
fix
Always use `unordered()` as a function wrapping the expected collection, like `assert actual == unordered(expected)`.
affects: >=0.4.0
gotchaDefault handling for `None` values within unordered collections was changed in version 0.3.0. This could subtly alter test results if your collections include `None` and you relied on the previous behavior.
fix
Review tests that involve collections with `None` elements if upgrading from `<0.3.0` to ensure the new behavior aligns with expectations. Consult the 0.3.0 release notes for details.
affects: >=0.3.0
Errors
Common errors & fixes
NameError: name 'unordered' is not defined
The 'unordered' matcher was used in a test without being explicitly imported from the pytest_unordered module.
fix
from pytest_unordered import unordered
ModuleNotFoundError: No module named 'pytest_unordered'
The 'pytest-unordered' package is not installed in the current Python environment, or there's a typo in the import statement.
fix
pip install pytest-unordered
TypeError: unordered() missing 1 required positional argument: 'iterable'
The 'unordered()' matcher was called without providing the expected collection (an iterable) as its required argument.
fix
assert actual_list == unordered([1, 2, 3])
Upgrade
Version history
0.8.0latest on PyPI · released Jun 16, 2026
Audit
Dependencies
pytestrequiredThis package is a pytest plugin and requires pytest to function.
Agent activity
13 hits · last 30 days
node
12
Resources
pytest-unordered — pip install pytest-unordered · libregistry