openwallet-foundation / acapy

ACA-Py is a foundation for building decentralized identity applications and services running in non-mobile environments.
https://aca-py.org
Apache License 2.0
419 stars 512 forks source link

:wrench: set default fixture scope for pytest-asyncio #3318

Closed ff137 closed 3 weeks ago

ff137 commented 3 weeks ago

Resolves PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset

jamshale commented 3 weeks ago

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.

sonarcloud[bot] commented 3 weeks ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

ff137 commented 3 weeks ago

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