Rich Assertions
Project description
Rich 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.
The current release also lacks a few of the assertions of the latest unittest version. Also, assert_equals only features very basic comparisons, rich comparison functions are planned for future releases.
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 Distribution
File details
Details for the file asserts-0.5.1.tar.gz
.
File metadata
- Download URL: asserts-0.5.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf2a498c289a89e41c056a007f39f58baacc8208b376d3069f2b1aaa9a92c2e9 |
|
MD5 | de8ae2681557e74b532db6fa78a5d818 |
|
BLAKE2b-256 | d3e7984c3b8b99fed393a07dcf34ee1822a6564f530668120f373576b8c51ca8 |