Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

peter-daly/assertive

Open more actions menu

Repository files navigation

Assertive

Assertive is a lightweight Python assertion library for writing declarative, composable test expectations.

Install

pip install assertive

Quickstart

from assertive import (
    contains,
    is_even,
    is_gt,
    is_lt,
    regex,
)

assert 5 == is_gt(4)
assert 5 == is_gt(4) & is_lt(6)
assert 4 == is_even()
assert "hello" == regex(r"^h.*o$")
assert [1, 2, 3] == contains(2)

You can compose criteria with boolean operators:

assert 5 == is_gt(4) & is_lt(6)  # AND
assert 5 == is_even() | is_lt(6)  # OR
assert 5 == is_even() ^ is_lt(6)  # XOR
assert 5 == ~is_even()  # NOT

Documentation

About

A library for writing concise high quality assertions for tests

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.