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

fix: set asyncio_default_fixture_loop_scope to a valid value #4685

Open
terriko opened this issue Jan 10, 2025 · 3 comments
Open

fix: set asyncio_default_fixture_loop_scope to a valid value #4685

terriko opened this issue Jan 10, 2025 · 3 comments
Labels
good first issue Good for newcomers

Comments

@terriko
Copy link
Contributor

terriko commented Jan 10, 2025

Description

We're getting a bunch of the following warnings when we run pytest

  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
/opt/hostedtoolcache/Python/3.10.16/x64/lib/python3.10/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"

Currently it looks like we're defaulting to "none" which isn't a valid option according to what pytest prints out during startup:

 ============================= test session starts ==============================
platform linux -- Python 3.10.16, pytest-8.3.4, pluggy-1.5.0 -- /opt/hostedtoolcache/Python/3.10.16/x64/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/cve-bin-tool/cve-bin-tool
configfile: setup.cfg
plugins: playwright-0.6.2, base-url-2.1.0, cov-6.0.0, xdist-3.6.1, asyncio-0.25.2, mock-3.14.0
asyncio: mode=strict, asyncio_default_fixture_loop_scope=None
created: 8/8 workers
8 workers [316 items]

You should figure out where to set that and fix it to something more appropriate. I'm not sure offhand which of the options it should be so you'll have to read the asyncio docs.

To reproduce

Steps to reproduce the behaviour:

  1. run pytest on any file that includes async tests

Expected behaviour: no warnings
Actual behaviour: the warning above appears

Anything else?

Short tips for new contributors:

  • cve-bin-tool's contributor docs
  • If you've contributed to open source but not this project, you might just want our checklist for a great pull request
  • cve-bin-tool uses https://www.conventionalcommits.org/ style for commit messages, and we have a test that checks the title of your pull request (PR). A good potential title for this one is in the title of this issue.
  • You can make an issue auto close by including a comment "fixes #ISSUENUMBER" in your PR comments where ISSUENUMBER is the actual number of the issue. This "links" the issue to the pull request.

Claiming issues:

  • You do not need to have an issue assigned to you before you work on it. To "claim" an issue either make a linked pull request or comment on the issue saying you'll be working on it.
  • If someone else has already commented or opened a pull request, assume it is claimed and find another issue to work on.
  • If it's been more than 1 week without progress, you can ask in a comment if the claimant is still working on it before claiming it yourself (give them at least 3 days to respond before assuming they have moved on).
@terriko terriko added the good first issue Good for newcomers label Jan 10, 2025
@terriko terriko changed the title fix: [bug description] fix: set asyncio_default_fixture_loop_scope to a valid value Jan 10, 2025
rukhshan23 added a commit to rukhshan23/cve-bin-tool that referenced this issue Jan 20, 2025
@rukhshan23
Copy link

rukhshan23 commented Jan 20, 2025

Hi @terriko. To fix the warning, I added 'asyncio_default_fixture_loop_scope = function' to 'setup.cfg'. This options seems appropriate, as it creates a new event loop for each test, providing isolation.

Should I open a pull request?

@terriko
Copy link
Contributor Author

terriko commented Jan 21, 2025

@rukhshan23 sounds good -- please go ahead and make a PR!

@rukhshan23
Copy link

rukhshan23 commented Jan 21, 2025

@terriko done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants