Skip to main content

Pytest Assertions

Scope of assertions methods, which provides simple interface for creating checks in autotests

Examples

from http import HTTPStatus

from assertions import assert_
from assertions.operators import Operators

assert_(True, what='user_id', operator=Operators.TRUTH)
assert_(None, what='user_id', operator=Operators.NULL)
assert_(5, 5, what='user_id', operator=Operators.EQUAL)
assert_('a', ['a'], what='user_id', operator=Operators.CONTAINS)
assert_(6, 5, what='user_id', operator=Operators.GT)
assert_(4, 5, what='user_id', operator=Operators.LT)
assert_(False, what='user_id', operator=Operators.NOT)
assert_(5, 6, what='user_id', operator=Operators.NOT_EQUAL)
assert_(200, HTTPStatus.OK, what='user_id', operator=Operators.STATUS_CODE)
assert_({"id": 1}, {"id": 1}, what='user_id', operator=Operators.EQUAL)

Build in solutions

from assertions import assert_all, assert_any, assert_lte

my_value = [{'name': 1}, {'name': 2}, {'name': 3}]
api_response_value = [{'name': 1}, {'name': 2}, {'name': 3}]

assert_all(api_response_value, my_value, 'my_value', ['name'])
assert_any(api_response_value, my_value, 'my_value', ['name'])

left_value = 1
right_value = 2
assert_lte(left_value, right_value, 'My value count')

Full list of solutions

assert_
assert_all
assert_any
assert_lte
assert_truth
assert_attr
assert_json
assert_response_status
assert_model_equal
validate_json

Release files for pytest-assertions 0.5.0

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

Source distribution (sdist)

Source distribution for pytest-assertions 0.5.0
File Size Uploaded
pytest_assertions-0.5.0.tar.gz 10.9 kB Details

Release files / pytest_assertions-0.5.0.tar.gz

Download URL pytest_assertions-0.5.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cf1c54e68557a128a18581bb003561f8d0a5cf1c04f272fa489efd2a524c6662
BLAKE2b-256 checksum
How to use checksums
0e541a548804bbf938fb4090b46100a3c1c4e1eb25fa1d9269bbf3c3ad5420bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.8.2 requests/2.27.1 setuptools/60.10.0 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.5.0 This release

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

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