Skip to content

Add a list of thread-unsafe fixtures and mark tests as thread-unsafe if usage is found #33

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

Merged
merged 2 commits into from
Mar 25, 2025

Conversation

andfoy
Copy link
Contributor

@andfoy andfoy commented Mar 21, 2025

@andfoy andfoy merged commit 1de039e into main Mar 25, 2025
9 checks passed
@andfoy andfoy deleted the blacklist_fixtures branch March 25, 2025 15:03
@@ -99,9 +99,16 @@ def closure(*args, **kwargs):
return inner


_thread_unsafe_fixtures = {
"capsys",
"recwarn",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And once that is done, can gh-14 be closed?

Copy link
Contributor Author

@andfoy andfoy Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only included the fixture names that are available by default by pytest, otherwise it would be difficult to cover all thread-unsafe fixtures that are defined by other plugins/libraries? This goes in the same spirit as the warning handling, it only covers functions defined either in the standard library or in pytest itself

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing we could do is add a way to set a list of fixtures to automatically mark as unsafe in the pytest configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, makes sense. And yes, making it easy to extend the list would be nice.

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.

3 participants