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

🔧 set default fixture scope for pytest-asyncio #3318

Merged

Conversation

ff137
Copy link
Contributor

@ff137 ff137 commented Oct 29, 2024

Resolves PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset

Resolves `PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset`

Signed-off-by: ff137 <ff137@proton.me>
@ff137 ff137 force-pushed the set-asyncio-default-fixture-scope branch from 496facd to c22f906 Compare October 29, 2024 13:00
@jamshale
Copy link
Contributor

I was going to change this with an upcoming PR. But we can change it here. I was going to change it to session scope as default. Not sure if there's a reason you chose module or not? I don't think it will really matter.

Copy link

@ff137
Copy link
Contributor Author

ff137 commented Oct 29, 2024

I was going to change this with an upcoming PR. But we can change it here. I was going to change it to session scope as default. Not sure if there's a reason you chose module or not? I don't think it will really matter.

Ah, the only reason for setting it to module level is because it's the lowest available scope.

I think the default in the next pytest-asyncio release will be "function" scope, so I first tried that. But then there are module-scope fixtures that depend on function-scope fixtures, which isn't allowed. So, module scope is a default that works. I guess that was the only reason.

The main difference will be in the lifecycle of the test fixtures. I think session-scope fixtures should be explicitly marked as such, since they have the longest lifecycle (created once and destroyed at end of test run). And those should probably be few and far between. Probably much of a muchness. But it makes sense that since the tests are highly modular (each module has its own tests folder), most test fixtures that don't have an explicitly defined scope should probably be function or module level.

I think function-level would make most sense, but that entails a review of all the fixtures that don't have a defined scope, and then setting only the ones that need it to module scope. Probably no need for that

@jamshale jamshale merged commit f499871 into openwallet-foundation:main Oct 29, 2024
10 checks passed
@ff137 ff137 deleted the set-asyncio-default-fixture-scope branch October 29, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants