FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fixtures: a few more cleanups by bluetech · Pull Request #12092 · pytest-dev/pytest · GitHub

fixtures: a few more cleanups - #12092

Merged
bluetech merged 4 commits into
pytest-dev:mainfrom
bluetech:fixture-cleanup
Mar 9, 2024
Merged

fixtures: a few more cleanups#12092
bluetech merged 4 commits into
pytest-dev:mainfrom
bluetech:fixture-cleanup

Conversation

bluetech commented Mar 8, 2024

Copy link
Copy Markdown
Member

These are a few more cleanup commits to the fixtures code, in the continuing quest to bring out its inner beauty :)

bluetech added 4 commits March 9, 2024 00:02
There are two non-optimal things in the current way scope checking is
done:

- It runs on `SubRequest`, but doesn't use the `SubRequest's scope,
  which is confusing. Instead it takes `invoking_scope` and
  `requested_scope`.

- Because `_check_scope` is only defined on `SubRequest` and not
  `TopRequest`, `_compute_fixture_value` first creates the `SubRequest`
  only then checks the scope (hence the need for the previous point).

Instead, also define `_check_scope` on `TopRequest` (always valid), and
remove `invoking_scope`, using `self._scope` instead.
- Separate the requesting from the requested.

- Avoid the term "factory", I think most people don't distinguish
  between "fixture" and "fixture function" (i.e. "factory") and would
  find the term "factory" unfamiliar.
This makes sure the scope is always compatible, and also allows using
`getfixturevalue` in `pytest_fixture_setup` so less internal magic.

nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks great, nice cleanup!

bluetech merged commit 437eb86 into pytest-dev:main Mar 9, 2024
bluetech deleted the fixture-cleanup branch March 9, 2024 06:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL