Pydiction: Deep Comparison and Assertion Library
Pydiction is a Python library for deep comparisons and assertions on complex data structures. It provides a flexible and customizable way to compare dictionaries and lists while supporting various comparison scenarios, including nested comparisons and negative tests.
Getting Started
These instructions will help you get started with using Pydiction for comparing data structures in your Python projects.
Prerequisites
Pydiction has the following prerequisites:
- Python 3.x
Installation
You can install Pydiction using pip:
pip install pydiction
Usage
Simple Usage
Here's a basic example of how to use Pydiction for deep comparisons:
from pydiction import Matcher, Contains
# Create a Matcher instance
matcher = Matcher()
# Define your actual and expected data structures
actual = {"a": 1, "b": 2}
expected = Contains({"a": 1})
# Perform the comparison and handle errors
try:
matcher.assert_declarative_object(actual, expected)
except AssertionError as e:
print(f"AssertionError: {e}")
Advanced
from pydiction import ANY_NOT_NONE, Matcher, ANY, Contains, DoesntContains, Expect, ExpectNot
matcher = Matcher()
actual = {
"name": "John",
"email": "john@example.com",
"age": 25,
"friends": [
{
"name": "Alice",
"email": "alice@example.com",
"age": 21,
}
],
"comments": [{ "text": "Great post!"}],
"likes": [
{
"title": "First Post",
"content": "This is my first post!",
},
{ "text": "Great post!"},
],
}
expected = {
"name": "John",
"age": Expect(10).__gt__,
"comments": DoesntContains([{"text": "not existing post!"}]),
"email": ExpectNot("gmail.com").__contains__,
"friends": [
{
"age": ANY_NOT_NONE,
"email": ANY_NOT_NONE,
"name": "Alice",
}
],
"likes": Contains(
[
{
"content": "This is my first post!",
"title": "First Post",
},
]
),
}
matcher.assert_declarative_object(actual, expected)
Contributing
If you'd like to contribute to Pydiction or report issues, please follow these guidelines:
- Fork the repository on GitHub.
- Clone your forked repository to your local machine.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with clear and concise commit messages.
- Push your changes to your forked repository.
- Create a pull request against the main repository.
Metadata
Release files for pydiction 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydiction-0.1.0.tar.gz | 5.9 kB | Without provenance | Details for pydiction-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydiction-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pydiction-0.1.0-py3-none-any.whl |
Total release size: 12.6 kB
Release files / pydiction-0.1.0.tar.gz
| Download URL | pydiction-0.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f93d7bd2e2a9f9be7e10ead3d9e8ea75ef3257a2c2452f0b2a775dddcd29206
|
|
BLAKE2b-256 checksum How to use checksums |
b70c6e8a8040390185f1bf30a579c2e9a98e42dbf379e846c615ba2bffd86bca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / pydiction-0.1.0-py3-none-any.whl
| Download URL | pydiction-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58f3679ceff25967ddc3fb9bfb2a5ac5f200d8317fe03021d11083cd75112a3c
|
|
BLAKE2b-256 checksum How to use checksums |
3720a6b5a97d17a8845d5a6a54c4d09fefa6d73d20aa1e1b634e95c2e75d09f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for pydiction 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.