1

I have my tests divided in multiple files with share a helpers.py with common functions to all tests. For example:

helpers.py

@pytest.fixture
def settings():


test_component_a.py

from helpers import settings
@pytest.fixture
def fixture_A(settings):
@pytest.fixture
def fixture_B(settings):
def test_A(fixture_A):
def test_B(fixture_B):

I would like to know why in any definition of def fixture_X(settings) I'm getting the "error" F811 - redefinition of unused 'settings' from line 1.

The code is working without any issues, but as I'm getting that error, I guess I'm misusing something.

EDIT: my question is not similar to the one you say it's similar. In that question, the OP is clearly defining the same function at the same level. In my case, there is only one definition of the function (fixture) in helpers.py. Then, the fixture is imported in another file, file which doesn't have any definition of the same function.

  • 1
    Possible duplicate of [How to avoid the redefinition of a function (PEP8 error F811)](https://stackoverflow.com/questions/30204197/how-to-avoid-the-redefinition-of-a-function-pep8-error-f811) – Watty62 May 10 '18 at 08:08
  • 1
    @Watty62 IMO it's not, see the edit. –  May 10 '18 at 08:15
  • 2
    ok, I found what's the issue. And as I said, it wasn't related to that question. The problem is the way `pytest` works. When I run `pytest`, it will load the fixtures of every file in the directory, so that's why it complains about a redefinition. –  May 10 '18 at 08:25
  • 2
    Your code is invalid. You cannot have function definitions with no content. Please post actual code that we can use to reproduce your bug. [mcve] – Håken Lid May 10 '18 at 08:26
  • Does this answer your question? [How do I get Flake8 to work with F811 errors?](https://stackoverflow.com/questions/43746413/how-do-i-get-flake8-to-work-with-f811-errors) – gerrit Feb 07 '20 at 10:12

1 Answers1

0

The problem is the way pytest works. When I run pytest, it will load the fixtures of every file in the directory, so that's why it complains about a redefinition