Skip to main content

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

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.1.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_maybe_context-0.1-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_maybe_context-0.1.tar.gz.

File metadata

  • Download URL: pytest_maybe_context-0.1.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.6 Linux/5.19.0-38-generic

File hashes

Hashes for pytest_maybe_context-0.1.tar.gz
Algorithm Hash digest
SHA256 aaaf8f17f14aa67e5ceec023241ae7bd780773cac23c9ef24db967ade141d91b
MD5 fedea181daeeb802ac876094730d3103
BLAKE2b-256 75e995625716411309e905fc055c950bc71509b9d2effa159baf76f69cd71963

See more details on using hashes here.

File details

Details for the file pytest_maybe_context-0.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_maybe_context-0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.6 Linux/5.19.0-38-generic

File hashes

Hashes for pytest_maybe_context-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c4e11638fab57a4902c2c61efd602ba2683b8a9e54d98457d9ac7c2725a5479
MD5 7a173a92d0e56a99cd4fe6229579cae8
BLAKE2b-256 e8e82f8be5caa709ee3f2901aa19baae4d51e6b10fd6b5541a2698c28f922f9d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1 This release

2 files

0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page