Simplify tests with warning and exception cases.
Project description
pytest-maybe-context
Makes it a bit easier to write warning and exception checks along other cases.
from pytest import mark, raises, warns
from pytest_maybe_context import maybe_context, not_context
@mark.parametrize(('buffering', 'expected'), (
(0, b'contents'),
(1, warns(RuntimeWarning)),
(.1, raises(TypeError))
))
def test_example(buffering, expected):
with maybe_context(expected):
file = open('file', 'rb', buffering)
if not_context(expected):
assert file.read() == expected
Installation
poetry add pytest-maybe-context --group dev
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
pytest_maybe_context-0.tar.gz
(1.8 kB
view hashes)
Built Distribution
Close
Hashes for pytest_maybe_context-0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 237098a5a71ec7387ffadcd8f4c8c87875be05a02dbd8e424913ad66fce4f86b |
|
MD5 | d5289b4d1711bd0230dbe6111541e1b9 |
|
BLAKE2b-256 | 8e374b06329b1b2d3b38dfc262875f716ae2b08b241094d973c20e30e71f7166 |