Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify configuration of session-scoped loops #676

Closed
seifertm opened this issue Nov 15, 2023 · 2 comments · Fixed by #687
Closed

Simplify configuration of session-scoped loops #676

seifertm opened this issue Nov 15, 2023 · 2 comments · Fixed by #687
Milestone

Comments

@seifertm
Copy link
Contributor

seifertm commented Nov 15, 2023

Pytest-asyncio users with a session-scoped event loop would have to add pytestmark = pytest.mark.asyncio(scope="session") for every package and subpackage to address the deprecation of event_loop fixture overrides (see discussion in #670).

This solution only applies to users that actually use test packages. Users that don't use test packages would have to add __init__.py files first or add pytestmark = pytest.mark.asyncio(scope="session") to each test module.

The goal of this issue is to have a more convenient way to configure session-scoped loops. Possible solutions:

  • a configuration fixture
  • a config option to set the default loop scope (mentioned previously, but I cannot find the reference)
  • a config option to set the default test scope
  • a pytest hook
@2e0byo
Copy link

2e0byo commented Nov 15, 2023

What about the suggested collection hook solution in that issue? Hooks are bit weird, but copying a snippet from the documentation isn't the end of the world?

@seifertm
Copy link
Contributor Author

I opted for your suggestion with the pytest hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants