-
Notifications
You must be signed in to change notification settings - Fork 8
Fixtures depended by other fixtures reported as unused imports #19
Comments
This is weird and sounds like a bug in pytest itself. The FWIW I think that what you're trying to do is an antipattern and you should probably move the fixture imports or even their declarations to |
AFAIK,
Yes I do agree with that. In general we should register the fixtures to I'm wondering if there's a specific use case that you don't want to import the fixtures into |
When you have a fixture that is local to the test module, not global for the whole test session. Also, you may override the global fixtures with some values specific to your module (by redefining fixtures with the same name). |
@webknjaz sorry for the confusion - that question was actually addressed to @Jaakkonen. I'm interested in the pattern they're using (manually import fixtures from |
Essentially trying not to have implicit dependencies. I think one option would be to make |
Describe the bug
When using a imported fixture with dependencies its dependencies need to be imported too. These imported dependencies are reported as unused by pylint-pytest.
To Reproduce
Package versions
(add any relevant pylint/pytest plugin here)
Folder structure
File content
pylint output with the plugin
$ pylint --load-plugins=pylint_pytest tests ************* Module tests.test_thing tests/test_thing.py:2:0: W0611: Unused my_fixture imported from fixtures (unused-import) ------------------------------------------------------------------ Your code has been rated at 8.57/10 (previous run: 8.57/10, +0.00)
(Optional) pytest output from fixture collection
Expected behavior
A linting warning is not raised from fixtures imported as dependencies if the dependent fixture is being used.
Additional context
Commenting the
my_fixture
out intest_thing.py
makes pylint-pytest pass but executing tests fails tomy_fixture
not being found.The text was updated successfully, but these errors were encountered: