Matchers for pytest
Project description
Pytest Matchers
Test your code with vague constrains
Quick Install
With pip
pip install pytest-matchers
With poetry
poetry add pytest-matchers [--group dev]
Usage
Examples on tests/examples
from random import random
from pytest_matchers import is_number
def test_random_number():
assert random() == is_number(min_value=0, max_value=1)
And when failing:
def test_random_number():
assert random() == is_number(min_value=1, max_value=2)
On pytest CLI
=================================== FAILURES ===================================
______________________________ test_random_number ______________________________
def test_random_number():
> assert random() == is_number(min_value=1, max_value=2)
E assert 0.9048172867693559 == To be a number between 1 and 2
E + where 0.9048172867693559 = random()
E + and To be a number between 1 and 2 = is_number(min_value=1, max_value=2)
tests/examples/test_example.py:6: AssertionError
=========================== short test summary info ============================
FAILED tests/examples/test_example.py::test_random_number - assert 0.9048172867693559 == To be a number between 1 and 2
============================== 1 failed in 0.02s ===============================
On PyCharm
tests/examples/test_example.py:4 (test_random_number)
0.9048172867693559 != To be a number between 1 and 2
Expected :To be a number between 1 and 2
Actual :0.9048172867693559
Matchers
is_numberis_stringis_listis_instancebetweenone_ofhas_attributeis_datetimeis_datetime_stringsame_valuedifferent_valueif_trueif_falsecaseis_dictis_strict_dictis_jsonis_uuidis_exceptionafter_applying_is
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
pytest_matchers-0.3.5.tar.gz
(15.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_matchers-0.3.5.tar.gz.
File metadata
- Download URL: pytest_matchers-0.3.5.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b26fcce9b071c7cdf5607911407c7ff53717e07326dcf7313646542c28990e29
|
|
| MD5 |
28bf2883ad45b1d5066b313376606cc2
|
|
| BLAKE2b-256 |
5ac98c016c26a153ab1a631e5748236c24b7cf0abaf9036894cc25fe6df9eee4
|
File details
Details for the file pytest_matchers-0.3.5-py3-none-any.whl.
File metadata
- Download URL: pytest_matchers-0.3.5-py3-none-any.whl
- Upload date:
- Size: 32.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4e03d31bd36f811c15aa5dcb374db6eeebd5aa4f4caf6b69474c5069004f443
|
|
| MD5 |
cc61afb43f91600c598205b77a9cda49
|
|
| BLAKE2b-256 |
a0bc9d09b36e39548d5eaa7c9b2934ddfa76a73124e5924245c78124081799f7
|