asserts 0.13.1
pip install asserts
Latest version
Released:
Stand-alone Assertions
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License (MIT)
- Author: Sebastian Rittau
- Requires: Python >=3.8.1
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
- Topic
Project description
Python Asserts
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()
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
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License (MIT)
- Author: Sebastian Rittau
- Requires: Python >=3.8.1
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
- Topic
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
Built Distribution
File details
Details for the file asserts-0.13.1.tar.gz
.
File metadata
- Download URL: asserts-0.13.1.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-31-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 958a69024f9c95905d1391bfede613e9fef987dbf74a399ef3952836c2c2a3bd |
|
MD5 | b4b3c8b24dcb9b2b601f0d9ab8ca2aef |
|
BLAKE2b-256 | aaa14ebe27df4fee2e09c972d9789adb89eb3199cd8ae577a3907ab2a852becf |
File details
Details for the file asserts-0.13.1-py3-none-any.whl
.
File metadata
- Download URL: asserts-0.13.1-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-31-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f76aa6cc9950326801a4c0ecc2fcc57af2e604effe8fb7136d2802aec0b8f7b3 |
|
MD5 | b4658e72c574b1da3f0449f129a3fbaf |
|
BLAKE2b-256 | 8fec1dd038c82f1dbe28daa0c9e7cffdf85bdc5b8161d23896f62da87754e834 |