Describe the bug
Since version 4.5.1 of pyfakefs there is an implementation of pathlib.Path.owner(), while previous version delate to the original pathlib implementation which uses os.stat. The new implementation assumes that the process owner is also the owner of the file. The result is an inconsistent view on ownership of the same file/directory depending on the method of obtaining the ownership data.
How To Reproduce
from pyfakefs import fake_filesystem, fake_pathlib
import pwd
fake_filesystem.set_uid(1004)
filesystem = fake_filesystem.FakeFilesystem()
os_module = fake_filesystem.FakeOsModule(filesystem)
pathlib_module = fake_pathlib.FakePathlibModule(filesystem)
filesystem.create_dir('test')
print(os.module.stat('test').st_uid)
print(pwd.getpwnam(pathlib_module.Path('test').owner()).pw_uid)
Your environment
Linux-5.15.0-30-generic-x86_64-with-redhat-7.7-Maipo
Python 3.6.8 (default, Jun 11 2019, 15:15:01
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
pyfakefs 4.5.6