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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

assertive-1.0.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: assertive-1.0.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.17 Linux/6.8.0-1021-azure

File hashes

Hashes for assertive-1.0.0.tar.gz
Algorithm Hash digest
SHA256 566fbd1f0264c5b6d6c87595205388ca9912bdc4d877cb14fcbfe2394d1c8661
MD5 c473f6e944898685a3ea7980460288a4
BLAKE2b-256 3a3d2b324e66e3599aacf572949be80ac9dbb67aedd3d7b466d145a323ef54e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: assertive-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.17 Linux/6.8.0-1021-azure

File hashes

Hashes for assertive-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2b64bb18aa8e8b156efbebf44c1b3249da6b90caf55e779ae16e8a0658329bc
MD5 b5073410cf648aa7fbf073120990f683
BLAKE2b-256 7aa51aec48b6c5c04669d6f5dafd4a55b65b51a5a48330293e470b2e6e902619

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