Scoped event loops based on pytest marks by seifertm · Pull Request #620 · pytest-dev/pytest-asyncio

added 2 commits

September 26, 2023 15:17
…coped asyncio event loop when a class has the mark.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…est.Pytester to avoid applying pytestmark to subsequent tests in the test module.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…vent loop when a module has the mark.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…nt loop implementation to pollute the test environment.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…event loop implementation from polluting the test environment.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…tor tests no longer requires an explicit event loop argument.

The wrapper retrieves the currently set loop via asyncio.get_event_loop, instead.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…the function-scoped event_loop fixture.

They rather provide a fixture with a different name, based on the nodeid of the pytest.Collector that has the "asyncio_event_loop" mark.

When a test requests the event_loop fixture and a dynamically generated event loop with class or module scope, pytest-asyncio will raise an error.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…p inside the event_loop fixture override rather than on the module-level.

This prevents the custom loop from being created during test collection time.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…policy.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…sing an iterable of policies.

This causes tests under the _asyncio_event_loop_ mark to be parametrized with the different loop policies.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>

@seifertm

…e executed in the same event loop.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>

@seifertm seifertm changed the title Provide a class-scoped asyncio event loop when a class has the asyncio mark Deprecate event_loop fixture overrides

Oct 9, 2023

@seifertm seifertm changed the title Deprecate event_loop fixture overrides Scoped event loops based on pytest marks

Oct 9, 2023

@seifertm

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>

@seifertm seifertm marked this pull request as ready for review

October 9, 2023 14:57

@seifertm

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>

@seifertm seifertm deleted the feat/scope-event-loop-based-on-asyncio-mark branch

October 13, 2023 10:38

@seifertm seifertm restored the feat/scope-event-loop-based-on-asyncio-mark branch

October 13, 2023 10:40

This was referenced

Oct 22, 2023

@seifertm seifertm deleted the feat/scope-event-loop-based-on-asyncio-mark branch

October 23, 2023 06:14

@seifertm seifertm restored the feat/scope-event-loop-based-on-asyncio-mark branch

October 23, 2023 08:17

@seifertm seifertm deleted the feat/scope-event-loop-based-on-asyncio-mark branch

October 23, 2023 08:33

This was referenced

Oct 23, 2023