deep-sorted
Motivation
When validating parsed JSON objects, schemas and other nested data structures in unit tests, order is typically not important. And yet I often find myself manually sorting the target structures when the internals of the tested function is modified such that order is changed. With this package, both the target and the actual structure can be recursively sorted before comparison.
Installation
Using poetry:
poetry add deep-sorted
Using pipenv:
pipenv install deep-sorted
Using pip:
pip install deep-sorted
Usage
from deep_sorted import deep_sorted
from datetime import datetime
one = {
"id": 9,
"name": "Ted Chiang",
"books": [
{
"id": 124,
"published": datetime(1991, 8, 1, 0, 0),
"title": "Understand",
"ratings": (6, 6, 3, 5, 6, 6, 0, 6, 0),
},
{
"id": 125,
"published": datetime(2019, 5, 7, 0, 0),
"title": "Exhalation",
},
],
}
two = {
"books": [
{
"published": datetime(2019, 5, 7, 0, 0),
"title": "Exhalation",
"id": 125,
},
{
"ratings": (3, 0, 0, 6, 6, 6, 6, 5, 6),
"id": 124,
"published": datetime(1991, 8, 1, 0, 0),
"title": "Understand",
},
],
"id": 9,
"name": "Ted Chiang",
}
assert deep_sorted(one) == deep_sorted(two)
Metadata
Release files for deep-sorted 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deep_sorted-0.0.3.tar.gz | 2.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deep_sorted-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.1 kB
Release files / deep_sorted-0.0.3.tar.gz
| Download URL | deep_sorted-0.0.3.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c962117596b7969e992664c673f7c5e300493b16d59f1b75f834e0f5fc1752bb
|
|
BLAKE2b-256 checksum How to use checksums |
33d1f3a50a8bd083e2c0d077065763c18197f322706f21f2e5832ce6f05da1bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.0 Linux/5.15.0-1034-azure
|
Release files / deep_sorted-0.0.3-py3-none-any.whl
| Download URL | deep_sorted-0.0.3-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9058f3fcd5d004a29a472271ee41c2d5168063105d5943c18430b4886263a4c
|
|
BLAKE2b-256 checksum How to use checksums |
5d4b83b0d3e8f9bf8590dd2522e8fd5e8102b851e16d383841ca848a2232f9bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.0 Linux/5.15.0-1034-azure
|