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

Add package property to request #12852

Open
apvd opened this issue Oct 4, 2024 · 3 comments
Open

Add package property to request #12852

apvd opened this issue Oct 4, 2024 · 3 comments
Labels
topic: fixtures anything involving fixtures directly or indirectly type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@apvd
Copy link

apvd commented Oct 4, 2024

What's the problem this feature will solve?

Fixtures can have function, class, and module specific behavior by inspecting request but not package specific behavior, even for package scoped fixtures.

Describe the solution you'd like

Add a package property to FeatureRequest, similar to the current module property, that returns the closest node of type Package.

Alternative Solutions

Current solution would be to have separate fixtures in each package, rather than one fixture with package-specific behavior.

@bluetech
Copy link
Member

Hi @apvd, can you describe your use case for getting the package?

I'd mention that packages are a bit different than the others in that packages can be nested, and thus there may be multiple package "scopes" active at the same time. So there a chance of some confusion, e.g.

root/
   __init__.py
   sub/
      __init__.py
      test_it.py

Say the test is in test_it.py and the fixture is in root. Using request.package in the fixture will return package sub, but maybe some users expect it to be root.

@apvd
Copy link
Author

apvd commented Nov 15, 2024

Hi @bluetech , that's true. It finds the closest node that's a package, which would be the innermost package in the hierarchy. The use case is that if you have a bunch of test modules that require a big fixture, you can create a convenient scope by putting them all into a package and then scoping the fixture on the package.

@RonnyPfannschmidt
Copy link
Member

Perhaps a packages property that's a list might be appropriate

The api seems a bit strangtho

@Zac-HD Zac-HD added type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature topic: fixtures anything involving fixtures directly or indirectly labels Dec 24, 2024
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: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

4 participants