pylint complains about fs
fixture name
#612
-
I'm using the pytest Could we add another name for the |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hm, conftest.py @pytest.fixture
def fake_filesystem(fs): # pylint:disable=invalid-name
yield fs and use @jmcgeheeiv - what do you think? |
Beta Was this translation helpful? Give feedback.
-
I like @mrbean-bremen's workaround. We could add it to our pytest template, which would avoid polluting the namespace, yet everybody sees it and can use it to avoid the PyLint issue if they like. |
Beta Was this translation helpful? Give feedback.
-
I like @mrbean-bremen's workaround too. Not polluting the namespace sounds like a good reason. Thanks for the suggestion! As a side note, something else I thought of is that there might be some weird behavior if both the |
Beta Was this translation helpful? Give feedback.
-
No, they will both point to the same fake fs and can be used interchangeably: def test_both_fixtures(fs, fake_filesystem):
fake_filesystem.create_file('/var/data/xx1.txt')
fs.create_file('/var/data/xx2.txt')
assert os.path.exists('/var/data/xx1.txt')
assert os.path.exists('/var/data/xx2.txt')
assert fs == fake_filesystem |
Beta Was this translation helpful? Give feedback.
Hm,
fs
is indeed a bit short, but it's also handy and it's quite clear that it stands forfile system
. I want to avoid polluting the fixture namespace with aliases that cannot be disabled, so I think the way to go here is to define your own fixture:conftest.py
and use
fake_filesystem
everywhere else. We could add this as a default, but at the moment I'm more inclined not to do this.@jmcgeheeiv - what do you think?