Pattern matching helper classes designed to allow for testing of complex data structures in a readable and logical format.
Project description
Jestspectation
Pattern matching helper classes designed to allow for testing of complex data structures in a readable and logical format.
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)
}
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.
You can enable it by adding the following lines to your conftest.py
pytest_plugins = ("jestspectation.pytest",)
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Jestspectation-0.3.0.tar.gz
(6.0 kB
view hashes)
Built Distribution
Close
Hashes for Jestspectation-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bb27aa2a9de73d7f5305e810309c5331edb05f2c9bbde36135550f78976e577 |
|
MD5 | 7f20d1cb2c391980775e2b232e547a92 |
|
BLAKE2b-256 | c17d2f4d39a50b9f400662790c4e69421e08c5e86e7d3c23439b1840b72a1bfe |