pytest-curio


Namepytest-curio JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/johnnoone/pytest-curio
SummaryPytest support for curio.
upload_time2024-10-06 21:53:06
maintainerNone
docs_urlNone
authorXavier Barbosa
requires_pythonNone
licenseApache License 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pytest-curio: pytest support for curio
======================================

curio_ code is written in the form of async/await, which makes it slightly more
difficult to test using normal testing tools. pytest-curio provides useful
fixtures and markers to make testing easier.

.. code-block:: python

    @pytest.mark.curio
    async def test_some_curio_code():
        res = await library.do_something()
        assert b'expected result' == res

pytest-curio has been strongly influenced by pytest-asyncio_.

.. _curio: https://github.com/dabeaz/curio
.. _pytest-asyncio: https://github.com/pytest-dev/pytest-asyncio

Features
--------

- fixtures for injecting curio kernel
- pytest markers for treating tests as curio coroutines


Installation
------------

To install pytest-curio, simply:

.. code-block:: bash

    $ pip install pytest-curio

This is enough for pytest to pick up pytest-curio.

Fixtures
--------

``kernel``
~~~~~~~~~~
Creates and injects a new instance of the default curio kernel. The kernel
will be stoped at the end of the test.

Note that just using the ``kernel`` fixture won't make your test function a
coroutine. You'll need to interact with the kernel directly, using methods
like ``kernel.run``. See the ``pytest.mark.curio`` marker for treating test
functions like coroutines.

.. code-block:: python

    def test_http_client(kernel):
        result = []
        async def my_coroutine(obj):
            result.append(obj)
        url = 'http://httpbin.org/get'
        task = kernel.run(my_coroutine(url))
        assert url in result

Markers
-------

``pytest.mark.curio``
~~~~~~~~~~~~~~~~~~~~~
Mark your test coroutine with this marker and pytest will execute it as an
curio task using the kernel provided by the ``kernel`` fixture. See the
introductory section for an example.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/johnnoone/pytest-curio",
    "name": "pytest-curio",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Xavier Barbosa",
    "author_email": "clint.northwood@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/70/e9/03b12b551e72720db4e0f619db618212ca0c35e6c5c2f1c09354f06d0322/pytest_curio-1.1.0.tar.gz",
    "platform": null,
    "description": "pytest-curio: pytest support for curio\n======================================\n\ncurio_ code is written in the form of async/await, which makes it slightly more\ndifficult to test using normal testing tools. pytest-curio provides useful\nfixtures and markers to make testing easier.\n\n.. code-block:: python\n\n    @pytest.mark.curio\n    async def test_some_curio_code():\n        res = await library.do_something()\n        assert b'expected result' == res\n\npytest-curio has been strongly influenced by pytest-asyncio_.\n\n.. _curio: https://github.com/dabeaz/curio\n.. _pytest-asyncio: https://github.com/pytest-dev/pytest-asyncio\n\nFeatures\n--------\n\n- fixtures for injecting curio kernel\n- pytest markers for treating tests as curio coroutines\n\n\nInstallation\n------------\n\nTo install pytest-curio, simply:\n\n.. code-block:: bash\n\n    $ pip install pytest-curio\n\nThis is enough for pytest to pick up pytest-curio.\n\nFixtures\n--------\n\n``kernel``\n~~~~~~~~~~\nCreates and injects a new instance of the default curio kernel. The kernel\nwill be stoped at the end of the test.\n\nNote that just using the ``kernel`` fixture won't make your test function a\ncoroutine. You'll need to interact with the kernel directly, using methods\nlike ``kernel.run``. See the ``pytest.mark.curio`` marker for treating test\nfunctions like coroutines.\n\n.. code-block:: python\n\n    def test_http_client(kernel):\n        result = []\n        async def my_coroutine(obj):\n            result.append(obj)\n        url = 'http://httpbin.org/get'\n        task = kernel.run(my_coroutine(url))\n        assert url in result\n\nMarkers\n-------\n\n``pytest.mark.curio``\n~~~~~~~~~~~~~~~~~~~~~\nMark your test coroutine with this marker and pytest will execute it as an\ncurio task using the kernel provided by the ``kernel`` fixture. See the\nintroductory section for an example.\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Pytest support for curio.",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/johnnoone/pytest-curio"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c024a29dd2b902ae667da6b9d123d7f54a2b344d229b94666a0f80c7d787b9b",
                "md5": "a2c88cd9945dffbb0c70d90c6acb5f3f",
                "sha256": "a2ce874c22491c327efcc33800c6f9abd6e5479aa6e9b824852b08783004b2a6"
            },
            "downloads": -1,
            "filename": "pytest_curio-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a2c88cd9945dffbb0c70d90c6acb5f3f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7941,
            "upload_time": "2024-10-06T21:53:04",
            "upload_time_iso_8601": "2024-10-06T21:53:04.984050Z",
            "url": "https://files.pythonhosted.org/packages/8c/02/4a29dd2b902ae667da6b9d123d7f54a2b344d229b94666a0f80c7d787b9b/pytest_curio-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "70e903b12b551e72720db4e0f619db618212ca0c35e6c5c2f1c09354f06d0322",
                "md5": "4285e0361bdc95715f45532058c62633",
                "sha256": "3dcc9ef052f7efc65d29edd4b2fc1033087ef264047a7332faa7022dce4dbc6d"
            },
            "downloads": -1,
            "filename": "pytest_curio-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4285e0361bdc95715f45532058c62633",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 26499,
            "upload_time": "2024-10-06T21:53:06",
            "upload_time_iso_8601": "2024-10-06T21:53:06.813052Z",
            "url": "https://files.pythonhosted.org/packages/70/e9/03b12b551e72720db4e0f619db618212ca0c35e6c5c2f1c09354f06d0322/pytest_curio-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-06 21:53:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "johnnoone",
    "github_project": "pytest-curio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pytest-curio"
}
        
Elapsed time: 2.79354s