chore(deps): update dependency pytest-asyncio to v0.17.0 #7368
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
==0.16.0->==0.17.0Release Notes
pytest-dev/pytest-asyncio
v0.17.0Compare Source
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-asyncio has been strongly influenced by
pytest-tornado.
Features
loop
fixtures
automatically by asyncio; provide strict mode if a test suite
should work with different async frameworks simultaneously, e.g.
asyncioandtrio.Installation
To install pytest-asyncio, simply:
This is enough for pytest to pick up pytest-asyncio.
Modes
Starting from
pytest-asyncio>=0.17, three modes are provided: auto,strict and legacy (default).
The mode can be set by
asyncio_modeconfiguration option inconfiguration
file:
The value can be overriden by command-line option for
pytestinvocation:
Auto mode
When the mode is auto, all discovered async tests are considered
asyncio-driven even if they have no
@pytest.mark.asynciomarker.All async fixtures are considered asyncio-driven as well, even if they
are decorated with a regular
@pytest.fixturedecorator instead ofdedicated
@pytest_asyncio.fixturecounterpart.asyncio-driven means that tests and fixtures are executed by
pytest-asyncioplugin.This mode requires the simplest tests and fixtures configuration and is
recommended for default usage unless the same project and its test
suite should execute tests from different async frameworks, e.g.
asyncioandtrio. In this case, auto-handling can break testsdesigned for other framework; plase use strict mode instead.
Strict mode
Strict mode enforces
@pytest.mark.asyncioand@pytest_asyncio.fixtureusage. Without these markers, tests andfixtures are not considered as asyncio-driven, other pytest plugin can
handle them.
Please use this mode if multiple async frameworks should be combined in
the same test suite.
Legacy mode
This mode follows rules used by
pytest-asyncio<0.17: tests are notauto-marked but fixtures are.
This mode is used by default for the sake of backward compatibility,
deprecation warnings are emitted with suggestion to either switching to
automode or usingstrictmode with@pytest_asyncio.fixturedecorators.
In future, the default will be changed.
Fixtures
event_loopCreates and injects a new instance of the default asyncio event loop. By
default, the loop will be closed at the end of the test (i.e. the
default fixture scope is
function).Note that just using the
event_loopfixture won't make your testfunction a coroutine. You'll need to interact with the event loop
directly, using methods like
event_loop.run_until_complete. See thepytest.mark.asynciomarker for treating test functions likecoroutines.
Simply using this fixture will not set the generated event loop as the
default asyncio event loop, or change the asyncio event loop policy in
any way. Use
pytest.mark.asynciofor this purpose.This fixture can be easily overridden in any of the standard pytest
locations (e.g. directly in the test file, or in
conftest.py) to use anon-default event loop. This will take effect even if you're using the
pytest.mark.asynciomarker and not theevent_loopfixture directly.If the
pytest.mark.asynciomarker is applied, a pytest hook willensure the produced loop is set as the default global loop. Fixtures
depending on the
event_loopfixture can expect the policy to beproperly modified when they run.
unused_tcp_portFinds and yields a single unused TCP port on the localhost interface.
Useful for binding temporary test servers.
unused_tcp_port_factoryA callable which returns a different unused TCP port each invocation.
Useful when several unused TCP ports are required in a test.
unused_udp_portandunused_udp_port_factoryWork just like their TCP counterparts but return unused UDP ports.
Async fixtures
Asynchronous fixtures are defined just like ordinary pytest fixtures,
except they should be decorated with
@pytest_asyncio.fixture.All scopes are supported, but if you use a non-function scope you will
need to redefine the
event_loopfixture to have the same or broaderscope. Async fixtures need the event loop, and so must have the same or
narrower scope than the
event_loopfixture.auto and legacy mode automatically converts async fixtures declared
with the standard
@pytest.fixturedecorator to asyncio-drivenversions.
Markers
pytest.mark.asyncioMark your test coroutine with this marker and pytest will execute it as
an asyncio task using the event loop provided by the
event_loopfixture. See the introductory section for an example.
The event loop used can be overridden by overriding the
event_loopfixture (see above).
In order to make your test code a little more concise, the pytest
pytestmark_ feature can be used to mark entire modules or classeswith this marker. Only test coroutines will be affected (by default,
coroutines prefixed by
test_), so, for example, fixtures are safe todefine.
In auto mode, the
pytest.mark.asynciomarker can be omitted, themarker is added automatically to async test functions.
Note about unittest
Test classes subclassing the standard
unittest library are
not supported, users are recommended to use
unitest.IsolatedAsyncioTestCase
or an async framework such as
asynctest.
Changelog
0.17.0 (22-01-13)
policies.
#168,
#188
[flaky]{.title-ref} or inherited asynchronous Hypothesis tests.
#178
#231
unused_udp_portandunused_udp_port_factoryfixtures(similar to
unused_tcp_portandunused_tcp_port_factorycounterparts.
#99
documentation
for details.
#125
KeyboardInterruptduring async fixture setupphase
#219
0.16.0 (2021-10-16)
0.15.1 (2021-04-22)
#209
#210
0.15.0 (2021-04-19)
Python 3.5, please use pytest-asyncio v0.14 or earlier.
unused_tcp_port_factoryfixture scope to 'session'.#163
#208
0.14.0 (2020-06-24)
#162,
and
event_loopfixture behavior now is coherent on all scopes.#164
0.12.0 (2020-05-04)
fixtures that have an implicit dependency on the event loop.
#156
0.11.0 (2020-04-20)
#152
pytest >= 5.4.0.
#142
pytest.skipsupport.#126
0.10.0 (2019-01-08)
pytest-asynciointegrates withHypothesis to support
@givenon async test functions using
asyncio.#102
#105
0.9.0 (2018-07-28)
event_loop_process_poolfixture andpytest.mark.asyncio_process_poolmarker (seehttps://bugs.python.org/issue34075 for deprecation and removal
details)
0.8.0 (2017-09-23)
careful event loop handling.
#64
0.7.0 (2017-09-08)
async fixtures. [#62
https://github.com/pytest-dev/pytest-asyncio/pull/62ll/62>]{.title-ref}
0.6.0 (2017-05-28)
pytestmarknow works on both module and class level.forbid_global_loopparameter has been removed.#45
asyncio.async()has been fixed.#51
0.5.0 (2016-09-07)
#31
event_loopfixture is again responsible for closing itself.This makes the fixture slightly harder to correctly override, but
enables other fixtures to depend on it correctly.
#30
pytest_fixture_setup. This allows setting the policy beforefixtures dependent on the
event_loopfixture run, thus allowingthem to take advantage of the
forbid_global_loopparameter. As aconsequence of this, we now depend on pytest 3.0.
#29
0.4.1 (2016-06-01)
#25
0.4.0 (2016-05-30)
event_loopfixtures simpler to override by closing them inthe plugin, instead of directly in the fixture.
#21
forbid_global_loopparameter.#21
0.3.0 (2015-12-19)
async/awaitsyntax.#17
0.2.0 (2015-08-01)
unused_tcp_port_factoryfixture.#10
0.1.1 (2015-04-23)
Initial release.
Contributing
Contributions are very welcome. Tests can be run with
tox, pleaseensure the coverage at least stays the same before you submit a pull
request.
Configuration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Never, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.