pytest-maybe-context


Namepytest-maybe-context JSON
Version 0.1 PyPI version JSON
download
home_pagehttps://github.com/wrwrwr/pytest-maybe-context
SummarySimplify tests with warning and exception cases.
upload_time2023-04-16 12:39:36
maintainer
docs_urlNone
authorwrwrwr
requires_python>=3.10,<4.0
licenseMIT
keywords pytest plugin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pytest-maybe-context

Makes it a bit easier to write warning and exception checks along other cases.

```python
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

```bash
poetry add pytest-maybe-context --group dev
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/wrwrwr/pytest-maybe-context",
    "name": "pytest-maybe-context",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "pytest,plugin",
    "author": "wrwrwr",
    "author_email": "code@wr.waw.pl",
    "download_url": "https://files.pythonhosted.org/packages/75/e9/95625716411309e905fc055c950bc71509b9d2effa159baf76f69cd71963/pytest_maybe_context-0.1.tar.gz",
    "platform": null,
    "description": "# pytest-maybe-context\n\nMakes it a bit easier to write warning and exception checks along other cases.\n\n```python\nfrom pytest import mark, raises, warns\nfrom pytest_maybe_context import maybe_context, not_context\n\n@mark.parametrize(('buffering', 'expected'), (\n    (0, b'contents'),\n    (1, warns(RuntimeWarning)),\n    (.1, raises(TypeError))\n))\ndef test_example(buffering, expected):\n    with maybe_context(expected):\n        file = open('file', 'rb', buffering)\n    if not_context(expected):\n        assert file.read() == expected\n```\n\n## Installation\n\n```bash\npoetry add pytest-maybe-context --group dev\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simplify tests with warning and exception cases.",
    "version": "0.1",
    "split_keywords": [
        "pytest",
        "plugin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e8e82f8be5caa709ee3f2901aa19baae4d51e6b10fd6b5541a2698c28f922f9d",
                "md5": "7a173a92d0e56a99cd4fe6229579cae8",
                "sha256": "9c4e11638fab57a4902c2c61efd602ba2683b8a9e54d98457d9ac7c2725a5479"
            },
            "downloads": -1,
            "filename": "pytest_maybe_context-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a173a92d0e56a99cd4fe6229579cae8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 2360,
            "upload_time": "2023-04-16T12:39:35",
            "upload_time_iso_8601": "2023-04-16T12:39:35.182796Z",
            "url": "https://files.pythonhosted.org/packages/e8/e8/2f8be5caa709ee3f2901aa19baae4d51e6b10fd6b5541a2698c28f922f9d/pytest_maybe_context-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "75e995625716411309e905fc055c950bc71509b9d2effa159baf76f69cd71963",
                "md5": "fedea181daeeb802ac876094730d3103",
                "sha256": "aaaf8f17f14aa67e5ceec023241ae7bd780773cac23c9ef24db967ade141d91b"
            },
            "downloads": -1,
            "filename": "pytest_maybe_context-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "fedea181daeeb802ac876094730d3103",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 1889,
            "upload_time": "2023-04-16T12:39:36",
            "upload_time_iso_8601": "2023-04-16T12:39:36.668053Z",
            "url": "https://files.pythonhosted.org/packages/75/e9/95625716411309e905fc055c950bc71509b9d2effa159baf76f69cd71963/pytest_maybe_context-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-16 12:39:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "wrwrwr",
    "github_project": "pytest-maybe-context",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pytest-maybe-context"
}
        
Elapsed time: 0.10868s