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

Warn when passing scope as positional argument #812

Closed
Cito opened this issue Apr 10, 2024 · 2 comments · Fixed by #886
Closed

Warn when passing scope as positional argument #812

Cito opened this issue Apr 10, 2024 · 2 comments · Fixed by #886

Comments

@Cito
Copy link
Member

Cito commented Apr 10, 2024

Recently I used pytest.mark.asyncio("session") instead of pytest.mark.asyncio(scope="session").

It took me quite a while to find out why the corresponding test was function scoped instead of session scoped.

It would be nice if either the scope could be passed as positional argument as well, or if there would be a helpful warning or error message in that case, instead of silently swallowing the positional argument.

I can contribute a PR for this feature if you let me know which exact behavior you prefer.

@seifertm
Copy link
Contributor

Good finding!

Since the purpose of a positional argument is not immediately obvious from the pytest.mark.asyncio name, I think we should force a keyword argument here. I agree that issuing a warning when passing a positional argument is an improvement. If you can (still) find the time, I'd appreciate a PR for this.

@Cito
Copy link
Member Author

Cito commented Jul 18, 2024

Implemented in PR #886 now with tests for all such cases of mistakes in arguments.

@seifertm seifertm linked a pull request Jul 30, 2024 that will close this issue
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