Skip to main content

A small assertion library for testing

Project description

Assertive

Assertive is a testing library that provides declarative assertions to you python tests.

Core of assertive

Assertive is built on two core concepts:

  1. Criteria
  2. Assertions

Criteria

Criteria are declarative statements that can be used with assert statements to give a richer test experience.

assert 5 == is_greater_than(4)
assert 5 == is_odd()
assert 5 != is_even()

Criteria can also be composed with logical operators to give a richer experience in writing tests

assert 5 == is_greater_than(4) & is_less_than(6) # Using AND
assert 5 == is_even() | is_less_than(6) # Using OR
assert 5 == is_even() ^ is_odd() # Using XOR
assert 5 == ~is_even()  # Using INVERT

Assertions

Criteria can be used with python's inbuilt assert statement or you can also use Assertions from the assertive library. The key difference between assert and Assertions is that Assertions give a more detailed Assertion Error when the test fails.

To use Assertions you simple use the assert_that() function

assert_that(5).matches(is_greater_than(4))
assert_that(5).matches(is_odd())
assert_that(5).matches(is_greater_than(4) & is_odd())
assert_that(5).does_not_match(is_even())

assert 5 == is_greater_than(4)
assert 5 == is_odd()
assert 5 == is_greater_than(4) & is_odd()
assert 5 != is_even()

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

assertive-0.2.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

assertive-0.2.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file assertive-0.2.0.tar.gz.

File metadata

  • Download URL: assertive-0.2.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-1024-azure

File hashes

Hashes for assertive-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fe83ee6379c3ac8e7f67eb3182cd59ca3b966cc6c4c3a9c7537cda781baadcd4
MD5 8247f8748c345ea8452cf2172e508b01
BLAKE2b-256 97f1c48ad56845762d6b3d221c84290f9b365b230e9ddc53c1a74c79522a07ab

See more details on using hashes here.

File details

Details for the file assertive-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: assertive-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-1024-azure

File hashes

Hashes for assertive-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68f4786d0fcd28f64229f1d84498e6965c5daaeb43aa552c796afd789576f219
MD5 09c5296f6989d4dfe4597a2d94def4fb
BLAKE2b-256 21e5de439500b8fa178692c71c198c7e3490f527623ee59ccb57c3a98c31f768

See more details on using hashes here.

Supported by

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