Skip to content

Commit

Permalink
Allow stat in unreadable directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbean-bremen committed Oct 19, 2019
1 parent 26b4c73 commit 947e83f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
3 changes: 2 additions & 1 deletion pyfakefs/fake_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,8 @@ def stat(self, entry_path, follow_symlinks=True):
# stat should return the tuple representing return value of os.stat
try:
file_object = self.resolve(
entry_path, follow_symlinks, allow_fd=True)
entry_path, follow_symlinks,
allow_fd=True, check_read_perm=False)
self.raise_for_filepath_ending_with_separator(
entry_path, file_object, follow_symlinks)

Expand Down
6 changes: 0 additions & 6 deletions pyfakefs/tests/fake_os_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5057,15 +5057,9 @@ def test_listdir_unreadable_dir_macos(self):
self.assert_raises_os_error(
errno.EACCES, self.os.listdir, self.dir_path)

@unittest.skipIf(TestCase.is_macos, 'Linux behavior')
def test_stat_file_in_unreadable_dir_linux(self):
self.assertEqual(0, self.os.stat(self.file_path).st_size)

@unittest.skipIf(not TestCase.is_macos, 'MacOS behavior')
def test_stat_file_in_unreadable_dir_macos(self):
self.assert_raises_os_error(
errno.EACCES, self.os.stat, self.file_path)


class RealOsUnreadableDirTest(FakeOsUnreadableDirTest):
def use_real_fs(self):
Expand Down

0 comments on commit 947e83f

Please sign in to comment.