Skip to main content

Jestspectation

Pattern matching tools to test complex data structures.

The design is inspired by the expect system from JavaScript's Jest testing framework.

>>> import jestspectation as expect
>>> assert {
...     "a": 1,
...     "b": 2,
...     "c": 3.0,
... } == {
...     "a": 1,
...     "b": expect.Any(int),
...     "c": expect.FloatApprox(2.5, magnitude=0.5)
... }

Documentation

Documentation can be found on GitHub Pages.

Installation

pip install jestspectation

Usage with Pytest

The library can be used as a pytest plugin, which can give access to much more detailed error messages when assertions fail.

This should result in output similar to the following

    def test_goodbye():
>       assert 1 == expect.Any(float)
E       assert Type mismatch
E         Expected any object of type float
E         Received 1 (int)

These advanced completions can also be used for most standard Python objects by wrapping the expected values in an Equals. For example:

    def test_lists():
>       assert expect.Equals([1, 2, 3, 4]) == [1, 2, 3, 5, 6]
E       assert [1, 2, 3, 4] == [1, 2, 3, 5, 6]
E         !! [3] 4 == 5
E            Value mismatch
E            Expected 4
E            Received 5
E         ++ [4] 6

To automatically use Jestspectation's diff parsing, you can configure Jestspectation.

>>> import jestspectation
>>> jestspectation.configure().pytest_all_diffs = True

Metadata

Release files for Jestspectation 1.4.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Jestspectation 1.4.5
File Size Uploaded Provenance Actions
jestspectation-1.4.5.tar.gz 14.2 kB Without provenance Details for jestspectation-1.4.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for Jestspectation 1.4.5
File Interpreter ABI Platform Actions
jestspectation-1.4.5-py3-none-any.whl Python 3 none any Details for jestspectation-1.4.5-py3-none-any.whl

Total release size: 37.4 kB

Release files / jestspectation-1.4.5.tar.gz

Download URL jestspectation-1.4.5.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ef709fd51d2e72950fc093c34d1fc5eacec568a8756a4f7f649cd5f6ba949570
BLAKE2b-256 checksum
How to use checksums
85dbec9c86ee59bcd2cd9dc08d43579aad1a2977cfebb16d997d69fde4b1d440
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1017-azure

Release files / jestspectation-1.4.5-py3-none-any.whl

Download URL jestspectation-1.4.5-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22f86f6b7b103b4244018510027a9b453f677097d7dfd4580a6d89e782669f0a
BLAKE2b-256 checksum
How to use checksums
31092c856764d7901e00560c444534ee4307e389a3b372d259fe6d0c837b3dcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1017-azure

Security for Jestspectation 1.4.5

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page