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
Built Distribution
Close
Hashes for pytest_maybe_context-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c4e11638fab57a4902c2c61efd602ba2683b8a9e54d98457d9ac7c2725a5479 |
|
MD5 | 7a173a92d0e56a99cd4fe6229579cae8 |
|
BLAKE2b-256 | e8e82f8be5caa709ee3f2901aa19baae4d51e6b10fd6b5541a2698c28f922f9d |