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

easier pattern for linter-friendly local fixtures #5645

Closed
belm0 opened this issue Jul 23, 2019 · 4 comments
Closed

easier pattern for linter-friendly local fixtures #5645

belm0 opened this issue Jul 23, 2019 · 4 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

@belm0
Copy link

belm0 commented Jul 23, 2019

#1444 added a linter-friendly way to deal with locally defined fixtures, but it's rather cumbersome.

I'd like to see the fixture decorator ignore any leading underscore of the wrapped function. Then usage would be:

@pytest.fixture
def _my_fixture():
    ...

def test_foo(my_fixture):
    ...
@RonnyPfannschmidt
Copy link
Member

I'm against adding a implicit name mangling system

@belm0
Copy link
Author

belm0 commented Jul 23, 2019

I can appreciate the aversion to implicitness-- however the fixture scheme is already rather implicit itself. I mean, define a function and then functions with an argument of the same name invoke it as a (stateful) factory...?

Prefixing local functions with underbar is the right thing to do anyway. The small renaming doesn't seem like a stretch.

@blueyed
Copy link
Contributor

blueyed commented Jul 23, 2019

@belm0
What linter is this about?
Maybe it should be made aware of pytest fixtures then maybe?

Prefixing local functions with underbar is the right thing to do anyway.

..if "unused" only I assume?

@Zac-HD Zac-HD added 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 labels Jul 25, 2019
@Zac-HD
Copy link
Member

Zac-HD commented Jul 6, 2024

Looks like we have a consensus against.

I'd recommend using standard context managers instead of fixtures, which linters should understand much better.

@Zac-HD Zac-HD closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 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