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

deadfixture doesn't support pytest-lazy-fixture #21

Closed
rougeth opened this issue Apr 29, 2018 · 7 comments
Closed

deadfixture doesn't support pytest-lazy-fixture #21

rougeth opened this issue Apr 29, 2018 · 7 comments
Labels

Comments

@rougeth
Copy link

rougeth commented Apr 29, 2018

The pytest-lazy-fixture plugin makes possible to use a fixtures inside pytest.mark.parametrize:

@pytest.fixture(params=[1, 2])
def one(request):
    return request.param

@pytest.mark.parametrize('arg1,arg2', [
    ('val1', pytest.lazy_fixture('one')),
])
def test_func(arg1, arg2):
    assert arg2 in [1, 2]

In this example, deadfixtures doesn't detect the fixture one being used and returns the warning.

Ref: There is a proposal in Pytest to make this behaviour possible out of the box: https://docs.pytest.org/en/latest/proposals/parametrize_with_fixtures.html

@spumer
Copy link

spumer commented Nov 1, 2019

Any updates?

@jllorencetti
Copy link
Owner

@spumer I'll take a look again at lazy fixture code, the last time I checked there was no reliable way to say that a fixture is being used, if that is the case, I'll close this with wont-fix.

@kazqvaizer
Copy link

I found that there is the same problem with fixtures that are only used in pytest.mark.usefixtures statements. They are also marked as not being used

@kazqvaizer
Copy link

I found that there is the same problem with fixtures that are only used in pytest.mark.usefixtures statements. They are also marked as not being used

Sorry, my bad, this fixture was really unused. The whole file with tests was ignored because of forgotten tests_ prefix in file name!

So this tool helps in refactoring, very nice!

@jeffersfp
Copy link

Holy moly! I'm facing this issue... What did you guys do to handle this problem?

@jllorencetti
Copy link
Owner

jllorencetti commented Jun 3, 2020

@jeffersfp sorry for the delay.
The way that I personally deal with it is by rewriting my tests so I don't need to use lazy-fixtures.

I'm planning a rewrite of this plugin to clean up the code a bit and make the options behavior more consistent, during this it might be possible that this problem is solved as a side-effect.
However it is just a maybe as I don't intend to explicitly support lazy-fixtures.

So, I'm closing this considering as a decision "by-design".

@anukul
Copy link

anukul commented Jan 17, 2023

@jllorencetti Agree with your approach of rewriting to avoid certain (anti-)patterns, but it may not be possible for fixtures overriden by the user that are called dynamically / lazily by libraries.

For this use case, I request that we address #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants