A utility package for making better test assertions
Asserty is a utility package that provides methods for better assertion in testing.
The package can be installed using
$ pip install asserty
You make assertions by importing the
assert_that function from the
from asserty import assert_that assert_that("str").not_equals("string") assert_that(5).is_in(range(10)) def myfunc(arg): if not isinstance(arg, str): raise TypeError() return arg+"yay" assert_that(myfunc).if_called_with(1).raises(TypeError) assert_that(myfunc).if_called_with("Hey-").returns("Hey-yay")
Outside a test context that does not handle
AssertionError you can import the equivalent function called
from asserty import that assert that("str").not_equals("string") assert that(5).is_in(range(10))
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.