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_attribute
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.1.0.tar.gz
(12.4 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.1.0.tar.gz.
File metadata
- Download URL: pytest_matchers-0.1.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
371958ca5547ca6ae34fed93d8108ee0101a23f1c8c0b17416e103c47a56cb51
|
|
| MD5 |
529acad580b8450c283ff06cdaa209f3
|
|
| BLAKE2b-256 |
d98fdb5d8bbf15c1cadfd1fbdca05eedb02fc5618abf1d6f85ab6d7a16c79a5f
|
File details
Details for the file pytest_matchers-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytest_matchers-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
625b5f7850ffed615ba3d09345e97499bf4aa6cefc1939d0a2badf604a35eb03
|
|
| MD5 |
7b78a2f8e6b1d39ed78e130bd1e80c0f
|
|
| BLAKE2b-256 |
62c3da585e88906a0b32a984cb185ef0a63cf34166e0fa9e2cb951a8827b42b1
|