soft-asserts
Soft assertions for Python/Pytest
Installation
pip install soft-assert
Usage
Assertion is performed immediately after the call check(),
but the expected result is obtained only after exit the context manager verify()
Quick example:
from soft_assert import check, verify
def test_something():
with verify():
check(1 == 1)
check(2 > 1, 'Message if test failed')
check('one' != 'two', 'Some message')
You can use asserts in loop:
from soft_assert import check, verify
def test_asserts_in_loop():
with verify():
for number in range(1, 10):
check(number % 2 == 0, '{number} is not a multiple of 2')
Also you can use it with pytest parametrized tests:
import pytest
from soft_assert import check, verify
@pytest.mark.parametrize('number', list(range(1, 10)))
def test_pytest_example(number):
with verify():
check(number % 2 == 0)
Example of output:
AssertionError: Failed conditions count: [ 4 ]
1. Failure: Custom message if test failed
2. Failure: Lists not equals
3. Failure: Your custom message; 4 < 5!
4. Failure: one != two
More examples you can find in test_example.py
Metadata
Release files for soft-assert 1.0.5
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 | |
|---|---|---|---|---|
| soft-assert-1.0.5.tar.gz | 2.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| soft_assert-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.3 kB
Release files / soft-assert-1.0.5.tar.gz
| Download URL | soft-assert-1.0.5.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20d2882eadda21a7198c56f64001d876837870bfe29c390b77d1b67852ad1bc2
|
|
BLAKE2b-256 checksum How to use checksums |
34c0f6c2ce71c35cbe24ace2bd13f6d7c71756c8e4865086224752bf3f97fa42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Release files / soft_assert-1.0.5-py3-none-any.whl
| Download URL | soft_assert-1.0.5-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ceb6ce13ac4d4a31f8b083f905be55ad9ec73d72e27870c410bd5c0a3a72149
|
|
BLAKE2b-256 checksum How to use checksums |
5b3f3061fee4f3f8df61399e7ca6de0284f5160555e88d27d6b415805f9657e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Security for soft-assert 1.0.5
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.