flake8 to test our code, and we're using
pytest with fixtures. The following code:
from staylists.tests.fixtures import fixture1 # noqa: F401 def test_case(fixture1): # noqa: F811 # Test goes here assert 1 == 1
lib/python/test.py:3:1: F811 redefinition of unused 'fixture1' from line 1 error during linting.
<li><strong>Why does it ignore the noqa flag?</strong> </li>
<li><strong>Is there a better way to avoid flagging this error?</strong> </li>
The F401 and F811 errors can be avoided by moving all fixtures into the <strong>conftest.py</strong> file. Pytest loads this file automatically and makes all fixtures inside available in all tests, even without explicit import statements.
More discussion about the file can be found here: In py.test, what is the use of conftest.py files?