unittest_assertions
Thin wrapper around the python builtin unittest allowing developers to use the builtin assertions for non-unittest use cases.
Key Features:
- Easy: Designed to make it be simple allowing developers to use the builtin unittest assertions for their own use cases.
- Great Developer Experience: Being fully typed, documented, and tested makes it great for editor support and extension.
- There is More!!!:
- assertify: Simple, Flexible, and Extendable python3.6+ library to evaluate an expression and return
True/Falseor raise anAssertionErrororException.
- assertify: Simple, Flexible, and Extendable python3.6+ library to evaluate an expression and return
Installation
pip install unittest-assertions
Examples
from unittest_assertions.identity import AssertIsInstance
assert_is_instance = AssertIsInstance(msg="Raised an AssertionError")
assert_is_instance("example str", int) # raise AssertionError("'example str' is not an instance of <class 'int'> : Raised an AssertionError")
from unittest_assertions import AssertEqual
assert_equal = AssertEqual()
assert_equal(1, 1)
assert_equal(first="hello", second="hello")
from unittest_assertions import AssertNotIn
assert_in = AssertNotIn()
assert_in(member=1, container=[5,2,3])
Asserters
Container
| Asserter | Expression |
|---|---|
| AssertIn | assert member in container |
| AssertNotIn | assert member not in container |
Control
| Asserter | Expression |
|---|---|
| AssertRaises | assert function raises expected_exception |
| AssertWarns | assert function warns expected_warning |
| AssertLogs | assert logger(level) |
Equality
| Asserter | Expression |
|---|---|
| AssertEqual | assert first == second |
| AssertNotEqual | assert first != second |
| AssertAlmostEqual | assert first ~= second |
| AssertNotAlmostEqual | assert first !~= second |
| AssertCountEqual | assert Counter(list(first) == Counter(list(second)) |
| AssertMultilineEqual | assert first.splitlines() == second.splitlines() |
| AssertSequenceEqual | assert seq1 == seq2 |
| AssertListEqual | assert list1 == list2 |
| AssertTupleEqual | assert tuple1 == tuple2 |
| AssertSetEqual | assert set1 == set2 |
| AssertDictEqual | assert dict1 == dict2 |
| AssertLess | assert a < b |
| AssertLessEqual | assert a <= b |
| AssertGreater | assert a > b |
| AssertGreater | assert a >= b |
Identity
| Asserter | Expression |
|---|---|
| AssertTrue | assert expr is True |
| AssertFalse | assert expr is False |
| AssertIs | assert exp1 is exp2 |
| AssertIsNot | assert exp1 is not exp2 |
| AssertIsNone | assert obj is None |
| AssertIsNotNone | assert obj is not None |
| AssertIsInstance | assert isinstance(obj,class) |
| AssertIsNotInstance | assert not isinstance(obj,class) |
Regex
| Asserter | Expression |
|---|---|
| AssertRaisesRegex | assert expected_regex in expected_exception_message |
| AssertWarnsRegex | assert expected_regex in expected_warning_message |
| AssertRegex | assert text in expected_regex |
| AssertNotRegex | assert text not in expected_regex |
Metadata
Release files for unittest-assertions 3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| unittest_assertions-3.1.tar.gz | 10.7 kB | Without provenance | Details for unittest_assertions-3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| unittest_assertions-3.1-py3-none-any.whl | Python 3 | none | any | Details for unittest_assertions-3.1-py3-none-any.whl |
Total release size: 23.0 kB
Release files / unittest_assertions-3.1.tar.gz
| Download URL | unittest_assertions-3.1.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d37a2460acaf53c8001a71b6b6d7e9e84d8e581dcb45af827849cce3ce171712
|
|
BLAKE2b-256 checksum How to use checksums |
4c61f42944d8fe46d11c6a635fd2ac404839eddba023bbdfaaa21e416c2042b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / unittest_assertions-3.1-py3-none-any.whl
| Download URL | unittest_assertions-3.1-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c1ab33d1e9b542a666f7f5ca8159fa02a1a01bf13a97a545b308104beb1e189
|
|
BLAKE2b-256 checksum How to use checksums |
63c606547f5a598faf9e52102f44d147171503d00bbf50e73c6a2ced97959556
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for unittest-assertions 3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.