Mystique
A loose data matcher to help you write Python tests
Introduction
Imagine you need to fetch some data from a JSON API in a test. It returns a payload with 10 fields, but you only care about two of them. With Mystique you can be as rigerous or loose as you want when checking data equivalence. Check against any combination of dictionaries, lists, and objects.
Examples
from matcher import Matcher
from matcher.predicates import Is, IsEval, IsType
data = {'foo': 'baz', 'bar': [1, 3]}
# exact match
assert Matcher().matches(data,
{'foo': 'baz', 'bar': [1, 3]})
# make sure one of the values just matches a type, instead of a value
assert Matcher().matches(data,
{'foo': 'baz', 'bar': IsType(list[int])})
# perhaps you don't care about the type at all. just that there is a value
assert Matcher().matches(data,
{'foo': 'baz', 'bar': Is()})
# check anything you want by writing your own logic
assert Matcher().matches(data,
{'foo': 'baz', 'bar': IsEval(lambda x: len(x) == 2)})
# if you dont care if a key is present or not, use 'sparse_dicts' settinvg
assert Matcher(sparse_dicts=True).matches(data, {'foo': 'baz'})
See tests/ for more examples.
Requirements
- python >= 3.7
- python >= 3.10 recommended
Development
pip install -r requirements.txt -r requirements_dev.txt
make test
Metadata
Release files for mystique 0.4.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 |
|---|---|---|---|---|
| mystique-0.4.0.tar.gz | 4.6 kB | Without provenance | Details for mystique-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mystique-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for mystique-0.4.0-py3-none-any.whl |
Total release size: 8.6 kB
Release files / mystique-0.4.0.tar.gz
| Download URL | mystique-0.4.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d289e178e0ea5a01a306b74efeed3e64b82ab1078bf4ef5da00537dd20f5f494
|
|
BLAKE2b-256 checksum How to use checksums |
446c5fa7cd6ff0c4d5bd330b05c204ce929b27eafb01d055a76f80474375d588
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Release files / mystique-0.4.0-py3-none-any.whl
| Download URL | mystique-0.4.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e364ec606936dc977b4969eff064fce0bf3fb47993f976213a356959bb396bc
|
|
BLAKE2b-256 checksum How to use checksums |
ec817613cdd0ab5f388e4ea92682736292386e5e35169a5a1db770a58e5866c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Security for mystique 0.4.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.