-
Notifications
You must be signed in to change notification settings - Fork 94
Closed
Labels
Description
Describe the bug
Getting E AttributeError: '_FakeAccessor' object has no attribute 'owner' when running with pytest. More specifically, happens in this function in pathlib.py
# pathlib.py:1228 gives error
def owner(self):
"""
Return the login name of the file owner.
"""
return self._accessor.owner(self)How To Reproduce
Run a pytest with code containing this line
owner = Path(file_path).owner()I have tried running on python 3.9.6, python 3.6.14. It works with the ladder, but not the former.
macOS-10.16-x86_64-i386-64bit
Python 3.9.6 (v3.9.6:db3ff76da1, Jun 28 2021, 11:49:53)
[Clang 6.0 (clang-600.0.57)]
pyfakefs-4.5.0
EDIT:
Dug a bit deeper, seems like somewhere in time Pathlib changed the implementation of the owner function. This is the old implementation:
def owner(self):
"""
Return the login name of the file owner.
"""
import pwd
return pwd.getpwuid(self.stat().st_uid).pw_nameThe new implementation have the owner attribute in the accessor, so a mock is needed for that