Skip to content

Commit b4e08dd

Browse files
committed
Add non-functional argument "effective_ids" to "os.access()"`
- fixes #585
1 parent 031b3c8 commit b4e08dd

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ The released versions correspond to PyPi releases.
1212
### Fixes
1313
* fixed handling of pipe descriptors in the fake filesystem
1414
(see [#581](../../issues/581))
15-
15+
* added non-functional argument `effective_ids` to `os.access`
16+
(see [#585](../../issues/585))
17+
1618
### Infrastructure
1719
* added automatic documentation build and check-in
1820

pyfakefs/fake_filesystem.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4282,7 +4282,8 @@ def ftruncate(self, fd, length):
42824282
file_object = self.filesystem.get_open_file(fd).get_object()
42834283
file_object.size = length
42844284

4285-
def access(self, path, mode, *, dir_fd=None, follow_symlinks=True):
4285+
def access(self, path, mode, *, dir_fd=None, effective_ids=False,
4286+
follow_symlinks=True):
42864287
"""Check if a file exists and has the specified permissions.
42874288
42884289
Args:
@@ -4291,12 +4292,16 @@ def access(self, path, mode, *, dir_fd=None, follow_symlinks=True):
42914292
os.F_OK, os.R_OK, os.W_OK, and os.X_OK.
42924293
dir_fd: If not `None`, the file descriptor of a directory, with
42934294
`path` being relative to this directory.
4295+
effective_ids: (bool) Unused. Only here to match the signature.
42944296
follow_symlinks: (bool) If `False` and `path` points to a symlink,
42954297
the link itself is queried instead of the linked object.
42964298
42974299
Returns:
42984300
bool, `True` if file is accessible, `False` otherwise.
42994301
"""
4302+
if effective_ids and self.filesystem.is_windows_fs:
4303+
raise NotImplementedError(
4304+
'access: effective_ids unavailable on this platform')
43004305
path = self._path_with_dir_fd(path, self.access, dir_fd)
43014306
try:
43024307
stat_result = self.stat(path, follow_symlinks=follow_symlinks)

pyfakefs/tests/fake_os_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,12 @@ def test_access_non_existent_file(self):
18961896
self.assertFalse(self.os.access(path, self.rwx))
18971897
self.assertFalse(self.os.access(path, self.rw))
18981898

1899+
def test_effective_ids_not_supported_under_windows(self):
1900+
self.check_windows_only()
1901+
path = self.make_path('foo', 'bar')
1902+
with self.assertRaises(NotImplementedError):
1903+
self.os.access(path, self.os.F_OK, effective_ids=True)
1904+
18991905
def test_chmod(self):
19001906
# set up
19011907
self.check_posix_only()

0 commit comments

Comments
 (0)