Hi Brianna, On Tue, Nov 26, 2013 at 14:45 +1100, Brianna Laugher wrote:
Hi,
Defining a fixture in the same file as a test that uses it triggers a pylint complaint:
"W0621:*Redefining name %r from outer scope (line %s)* Used when a variable’s name hide a name defined in the outer scope."
If the fixture was in conftest.py it would be fine. But it is nice to have fixtures in the same file if they are only used there. Does everybody just disable this message? I find it useful in general, I would prefer not to disable it completely.
I use flakes and pep8 (pytest-flakes and pytest-pep8) and don't get this error. What you can immediately do but which is not pretty is to use the old naming scheme together with a decorator: import pytest @pytest.fixture def pytest_funcarg__somefixture(...): ... This should avoid the pylint warning. Alternatively, putting the fixture on a class-level might avoid the problem: class TestClass: @pytest.fixture def fix(self): .... def test_fix(self, fix): ... but i haven't tried if pylint likes that. best, holger