Skip to content

built-in fixtures and multiple scopes #6888

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

Open
sashkab opened this issue Mar 10, 2020 · 3 comments
Open

built-in fixtures and multiple scopes #6888

sashkab opened this issue Mar 10, 2020 · 3 comments
Labels
topic: fixtures anything involving fixtures directly or indirectly type: enhancement new feature or API change, should be merged into features branch

Comments

@sashkab
Copy link

sashkab commented Mar 10, 2020

Currently if I need to create a fixture which has scope other than function, I have to re-implement every built-in fixture locally. If pytest does not support calling fixtures with multiple scopes, it should at least provide built-in fixtures with multiple scope. For example:

  • monkeypatch
  • monkeypatch_session
  • monkeypatch_module

Same goes for tmpdir, tmp_path, etc.

@RonnyPfannschmidt
Copy link
Member

there was a initial plan to provide those via multi scoped fixtures back for pytest 3.0 which failed

@nicoddemus would it be sensible to provide this workaround/pattern until pytest is actually structured to deliver multi scope fixtures

@Zac-HD Zac-HD added topic: fixtures anything involving fixtures directly or indirectly type: enhancement new feature or API change, should be merged into features branch labels Mar 10, 2020
@Zac-HD
Copy link
Member

Zac-HD commented Mar 10, 2020

If jumping directly to multi-scoped fixtures is not feasible*, this sounds like a good workaround to me. I know Hypothesis would use monkeypatch_session!

*though variable fixture scope sounds rather prone to user error, and I'm unsure that it's a good idea at all...

@casperdcl
Copy link

duplicate of longstanding #363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: fixtures anything involving fixtures directly or indirectly type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

4 participants