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

pytest.mark.usefixtures fixtures marked as unused #10

Closed
yedpodtrzitko opened this issue Mar 28, 2018 · 4 comments
Closed

pytest.mark.usefixtures fixtures marked as unused #10

yedpodtrzitko opened this issue Mar 28, 2018 · 4 comments

Comments

@yedpodtrzitko
Copy link

Hi,
this library is quite helpful, thanks for creating it.

However there's an issue when marker pytest.mark.usefixtures [1] is used - such fixture is marked as unused anyway.

Cheers,
yed

[1] https://docs.pytest.org/en/latest/fixture.html#using-fixtures-from-classes-modules-or-projects

@jllorencetti
Copy link
Owner

hi @yedpodtrzitko, thanks for taking your time to open this issue.

that's strange, this behavior should be covered already in this test.
could you provide more details?

@yedpodtrzitko
Copy link
Author

Thanks for your answer. That's really strange, indeed.

The fixtures in project I was testing it with are quite mess, so I'll try extract a minimal reproducible example.

@jllorencetti
Copy link
Owner

@yedpodtrzitko could you please try to replicate this problem again with the newest version 1.0.1?
two fixes are made into this release that can solve this :)

@yedpodtrzitko
Copy link
Author

Hi,
sorry for no response from my side ...priorities.

Anyway, I tried to update to the new version. The output is much cleaner now. Before this release, there was a lot of items in the output as this:

Fixture name: transfers, location: <string>:3
Fixture name: transfers__bid, location: <string>:3
Fixture name: transfers__booking, location: <string>:3
Fixture name: transfers__created_at, location: <string>:3
Fixture name: transfers__tid, location: <string>:3
Fixture name: transfers__updated_at, location: <string>:3

Now this is gone, which is great. There is only one fixture in the output left, which is reported as unused, even if it is used. But after investigating a bit, I figured out the reason - the actual test was missing test_ in the name of its function, so the test collector skiped it, and the test never run.

So the reporting is actually correct, but for a different reason than I thought. Example below:

import pytest

@pytest.fixture
def mock_errorlib(mocker):
    return mocker.patch('api_clients.emailing.errorlib')

def send_extras_failed(mock_errorlib):  # this is the "test", which is using fixture, but it doesnt run
    assert mock_errorlib.sentry_client.captureException.callc_count == 1

This makes me think if it would be possible to make the output somehow hinting, that maybe the fixture is used, but for a thing, which is not a test. But that's definitely out of scope of this issue, so I'm gonna close it.

Thanks for your response, keep up the great work 👍

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

No branches or pull requests

2 participants