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.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: assertive-0.2.1.tar.gz
  • Upload date:
  • Size: 12.2 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.1.tar.gz
Algorithm Hash digest
SHA256 41038333f4c19919e7c0d4e378c3702e6d4c953513ef3c2628d6df458e67c976
MD5 a75be558740a0736d2aa01f0ca66d4c5
BLAKE2b-256 4fd5233a31e665d128fd7752616e1abe7692b5f6e5e4b11aeb7880d4d374012e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: assertive-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9986f53ebe91c8b329618fd7b66e64236c6645eb4e5a5b56c05ba24a58a4da6
MD5 d42c6eff2c40c2b8b13b4cca03729ac5
BLAKE2b-256 65cff6c9092edd38a53687545bb5585f727fa00664da1456bbe0261da5279c20

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