Stand-alone Assertions
Project description
Stand-alone Assertions for Python
This package provides a few advantages over the assertions provided by unittest.TestCase:
Can be used stand-alone, for example:
In test cases, not derived from TestCase.
In fake and mock classes.
In implementations as rich alternative to the assert statement.
PEP 8 compliance.
Custom stand-alone assertions can be written easily.
Arguably a better separation of concerns, since TestCase is responsible for test running only, if assertion functions are used exclusively.
There are a few regressions compared to assertions from TestCase:
The default assertion class (AssertionError) can not be overwritten. This is rarely a problem in practice.
asserts does not support the addTypeEqualityFunc() 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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for asserts-0.7.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c06f9249eb0427a69d6bc2a76489eee3706d084e756ec89df41d3c4b1629938 |
|
MD5 | c8d30b847a05c62dca3a90195b1f12fd |
|
BLAKE2b-256 | 8e8ade82103b6d00f586dc01c1d0166817832b1e7c829db95c879a698a7a83dc |