Sourced from pytest-asyncio's releases.
pytest-asyncio 0.19.0
title: 'pytest-asyncio: pytest support for asyncio'
pytest-asyncio is an Apache2 licensed library, written in Python, for testing asyncio code with pytest.
asyncio code is usually written in the form of coroutines, which makes it slightly more difficult to test using normal testing tools. pytest-asyncio provides useful fixtures and markers to make testing easier.
@pytest.mark.asyncio async def test_some_asyncio_code(): res = await library.do_something() assert b"expected result" == res
pytest-asyncio has been strongly influenced by pytest-tornado.
Features
- fixtures for creating and injecting versions of the asyncio event loop
- fixtures for injecting unused tcp/udp ports
- pytest markers for treating tests as asyncio coroutines
- easy testing with non-default event loops
- support for [async def]{.title-ref} fixtures and async generator fixtures
- support auto mode to handle all async fixtures and tests automatically by asyncio; provide strict mode if a test suite should work with different async frameworks simultaneously, e.g.
asyncio
andtrio
.Installation
... (truncated)
Sourced from pytest-asyncio's changelog.
0.19.0 (22-07-13)
- BREAKING: The default
asyncio_mode
is now strict.[#293](https://github.com/pytest-dev/pytest-asyncio/issues/293) <https://github.com/pytest-dev/pytest-asyncio/issues/293>
_- Removes
setup.py
since all relevant configuration is presentsetup.cfg
. Users requiring an editable installation of pytest-asyncio need to use pip v21.1 or newer.[#283](https://github.com/pytest-dev/pytest-asyncio/issues/283) <https://github.com/pytest-dev/pytest-asyncio/issues/283>
_- Declare support for Python 3.11.
0.18.3 (22-03-25)
- Adds
pytest-trio <https://pypi.org/project/pytest-trio/>
_ to the test dependencies- Fixes a bug that caused pytest-asyncio to try to set up async pytest_trio fixtures in strict mode.
[#298](https://github.com/pytest-dev/pytest-asyncio/issues/298) <https://github.com/pytest-dev/pytest-asyncio/issues/298>
_0.18.2 (22-03-03)
- Fix asyncio auto mode not marking static methods.
[#295](https://github.com/pytest-dev/pytest-asyncio/issues/295) <https://github.com/pytest-dev/pytest-asyncio/issues/295>
_- Fix a compatibility issue with Hypothesis 6.39.0.
[#302](https://github.com/pytest-dev/pytest-asyncio/issues/302) <https://github.com/pytest-dev/pytest-asyncio/issues/302>
_0.18.1 (22-02-10)
- Fixes a regression that prevented async fixtures from working in synchronous tests.
[#286](https://github.com/pytest-dev/pytest-asyncio/issues/286) <https://github.com/pytest-dev/pytest-asyncio/issues/286>
_0.18.0 (22-02-07)
- Raise a warning if
@​pytest
.mark.asyncio is applied to non-async function.[#275](https://github.com/pytest-dev/pytest-asyncio/issues/275) <https://github.com/pytest-dev/pytest-asyncio/issues/275>
_- Support parametrized
event_loop
fixture.[#278](https://github.com/pytest-dev/pytest-asyncio/issues/278) <https://github.com/pytest-dev/pytest-asyncio/issues/278>
_0.17.2 (22-01-17)
- Require
typing-extensions
on Python`_- Fix a regression in tests collection introduced by 0.17.1, the plugin works fine with non-python tests again.
[#267](https://github.com/pytest-dev/pytest-asyncio/issues/267) <https://github.com/pytest-dev/pytest-asyncio/issues/267>
_0.17.1 (22-01-16)
- Fixes a bug that prevents async Hypothesis tests from working without explicit
asyncio
marker when--asyncio-mode=auto
is set.[#258](https://github.com/pytest-dev/pytest-asyncio/issues/258) <https://github.com/pytest-dev/pytest-asyncio/issues/258>
_- Fixed a bug that closes the default event loop if the loop doesn't exist
[#257](https://github.com/pytest-dev/pytest-asyncio/issues/257) <https://github.com/pytest-dev/pytest-asyncio/issues/257>
_- Added type annotations.
[#198](https://github.com/pytest-dev/pytest-asyncio/issues/198) <https://github.com/pytest-dev/pytest-asyncio/issues/198>
_- Show asyncio mode in pytest report headers.
[#266](https://github.com/pytest-dev/pytest-asyncio/issues/266) <https://github.com/pytest-dev/pytest-asyncio/issues/266>
_- Relax
asyncio_mode
type definition; it allows to support pytest 6.1+.[#262](https://github.com/pytest-dev/pytest-asyncio/issues/262) <https://github.com/pytest-dev/pytest-asyncio/issues/262>
_0.17.0 (22-01-13)
pytest-asyncio
no longer alters existing event loop policies.[#168](https://github.com/pytest-dev/pytest-asyncio/issues/168) <https://github.com/pytest-dev/pytest-asyncio/issues/168>
,[#188](https://github.com/pytest-dev/pytest-asyncio/issues/188) <https://github.com/pytest-dev/pytest-asyncio/issues/168>
- Drop support for Python 3.6
- Fixed an issue when pytest-asyncio was used in combination with
flaky
or inherited asynchronous Hypothesis tests.[#178](https://github.com/pytest-dev/pytest-asyncio/issues/178) <https://github.com/pytest-dev/pytest-asyncio/issues/178>
_[#231](https://github.com/pytest-dev/pytest-asyncio/issues/231) <https://github.com/pytest-dev/pytest-asyncio/issues/231>
_- Added
flaky <https://pypi.org/project/flaky/>
_ to test dependencies- Added
unused_udp_port
andunused_udp_port_factory
fixtures (similar tounused_tcp_port
andunused_tcp_port_factory
counterparts.[#99](https://github.com/pytest-dev/pytest-asyncio/issues/99) <https://github.com/pytest-dev/pytest-asyncio/issues/99>
_- Added the plugin modes: strict, auto, and legacy. See
documentation <https://github.com/pytest-dev/pytest-asyncio#modes>
_ for details.[#125](https://github.com/pytest-dev/pytest-asyncio/issues/125) <https://github.com/pytest-dev/pytest-asyncio/issues/125>
_- Correctly process
KeyboardInterrupt
during async fixture setup phase[#219](https://github.com/pytest-dev/pytest-asyncio/issues/219) <https://github.com/pytest-dev/pytest-asyncio/issues/219>
_
... (truncated)
2da33c4
docs: Prepare v0.19.0 release. (#385)07beb80
opt into strict mode by default (#380)25c54a5
Clarify documentation of event_loop fixture (#375)49f07a4
Bump typing-extensions from 4.2.0 to 4.3.0 in /dependencies/default (#382)739198b
Bump hypothesis from 6.48.0 to 6.48.3 in /dependencies/default (#381)db72f25
Bump importlib-metadata from 4.11.4 to 4.12.0 in /dependencies/default (#378)4cf16cf
Bump hypothesis from 6.47.3 to 6.48.0 in /dependencies/default (#377)f13c85f
docs: Fix typo in README.b463f72
Python 3.11 support (#370)860ff51
Bump hypothesis from 6.47.2 to 6.47.3 in /dependencies/default (#373)