Metadata-Version: 2.3
Name: assertive
Version: 1.0.0
Summary: A small assertion library for testing
License: MIT
Author: Peter Daly
Requires-Python: >=3.9,<4.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: bidict (>=0.23.1,<0.24.0)
Project-URL: Documentation, https://peter-daly.github.io/assertive/
Project-URL: Homepage, https://github.com/peter-daly/assertive
Project-URL: Repository, https://github.com/peter-daly/assertive
Description-Content-Type: text/markdown

# 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.

```python
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

```python
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

```python
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()
```
