Skip to main content

Pytest Assertions

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_assertions-0.4.1.tar.gz (10.8 kB view details)

Uploaded Source

File details

Details for the file pytest_assertions-0.4.1.tar.gz.

File metadata

  • Download URL: pytest_assertions-0.4.1.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pytest_assertions-0.4.1.tar.gz
Algorithm Hash digest
SHA256 29fa713b0bb9470b0049442137ca6b302d66658f5723794fe9c1b2e735ac5a6e
MD5 86d63e374c6f4b242d1c75be10a622c7
BLAKE2b-256 8808ba7c5132346272019d664f3af30e0b97646b248ed729f52f25c519e906fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page