Stand-alone Assertions for Python
This package provides a few advantages over the assertions provided by unittest.TestCase:
There are a few regressions compared to assertions from TestCase:
AssertionError
) can not be overwritten. ThisaddTypeEqualityFunc()
functionality.Usage:
>>> from asserts import assert_true, assert_equal, assert_raises
>>> my_var = 13
>>> assert_equal(13, my_var)
>>> assert_true(True, msg="custom failure message")
>>> with assert_raises(KeyError):
... raise KeyError()
Failure messages can be customized:
>>> assert_equal(13, 14, msg_fmt="{got} is wrong, expected {expected}")
Traceback (most recent call last):
...
AssertionError: 14 is wrong, expected 13