You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the pytest pyfakefs fixture in a project. The project is linted with pylint. pylint warns C0103: Argument name "fs" doesn't conform to snake_case naming style (invalid-name). I know that I could add fs to the list of good-names for pylint, but I would prefer not to do that because then the name would be accepted everywhere. I could also add # pylint: disable=invalid-name everywhere I use the fixture, but that isn't very clean.
Could we add another name for the pytest fixture? Something like fake_filesystem?
Hm, fs is indeed a bit short, but it's also handy and it's quite clear that it stands for file 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:
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.
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 fs and fake_filesystem fixtures are used in the same unit test?
Activity
mrbean-bremen commentedon Jun 7, 2021
Hm,
fsis 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_filesystemeverywhere 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?
jmcgeheeiv commentedon Jun 7, 2021
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.
Add example for alias for fs fixture
Add example for alias for fs fixture
AustinScola commentedon Jun 7, 2021
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
fsandfake_filesystemfixtures are used in the same unit test?mrbean-bremen commentedon Jun 8, 2021
No, they will both point to the same fake fs and can be used interchangeably:
Add example for alias for fs fixture (#610)
Add example for alias for fs fixture (#610) - see #609
mrbean-bremen commentedon Jun 10, 2021
I'm converting this into a discussion Q/A issue.