os.access() is not properly faked, wrong signature since python3.3
See original GitHub issueDescribe the bug Signature of os.access() (since Python3.3) is:
os.access = access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True)
If some code uses the “effective_ids” feature, it does not work when using pyfakefs because the “os.access” function in fake_filesystem.py::FakeOsModule::access() does not match the signature:
def access(self, path, mode, *, dir_fd=None, follow_symlinks=True):
How To Reproduce
import os
def test_fakefs(fs):
file_path = '/test/file.txt'
assert not os.access(file_path, os.R_OK)
fs.create_file(file_path)
assert os.access(file_path, os.R_OK)
def test_fakefs_effective_ids(fs):
file_path = '/test/file.txt'
assert not os.access(file_path, os.R_OK, effective_ids=True)
fs.create_file(file_path)
assert os.access(file_path, os.R_OK, effective_ids=True)
» pytest test_os_access.py
```» pytest test_os_access.py
===================================== test session starts =====================================
platform freebsd12 -- Python 3.7.9, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /usr/home/armin/git-repos/link-m/py-linkm, inifile: tox.ini
plugins: mongo-2.0.0, mock-3.5.1, Faker-5.6.1, faker-2.0.0, pyfakefs-4.3.3
collected 2 items
test_os_access.py .F [100%]
========================================== FAILURES ===========================================
__________________________________ test_fakefs_effective_ids __________________________________
fs = <pyfakefs.fake_filesystem.FakeFilesystem object at 0x803f6ce10>
def test_fakefs_effective_ids(fs):
file_path = '/test/file.txt'
> assert not os.access(file_path, os.R_OK, effective_ids=True)
E TypeError: access() got an unexpected keyword argument 'effective_ids'
/usr/home/armin/git-repos/link-m/py-linkm/test_os_access.py:11: TypeError
=================================== short test summary info ===================================
FAILED test_os_access.py::test_fakefs_effective_ids - TypeError: access() got an unexpected ...
================================= 1 failed, 1 passed in 1.05s =================================
Your environment Please run the following and paste the output.
python -c "import platform; print(platform.platform())"
python -c "import sys; print('Python', sys.version)"
python -c "from pyfakefs.fake_filesystem import __version__; print('pyfakefs', __version__)"
FreeBSD-12.1-RELEASE-p10-amd64-64bit-ELF Python 3.7.9 (default, Dec 3 2020, 01:19:24) [Clang 8.0.1 (tags/RELEASE_801/final 366581)] pyfakefs 4.3.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
os.access() is not properly faked, wrong signature since python3.3 ...
Describe the bug. Signature of os.access() (since Python3.3) is: os.access = access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True).
Read more >python - urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error
There is nothing wrong with the URL and it can be successfully verified with the common trusted certificates. So you should better not...
Read more >os — Miscellaneous operating system interfaces — Python ...
Note that since getenv() uses os.environ , the mapping of getenv() is similarly also captured on import, and the function may not reflect...
Read more >Python import: Advanced Techniques and Tips
Using imports properly will make you more productive, allowing you to reuse code while keeping your projects maintainable. This tutorial will provide a...
Read more >ThreadPoolExecutor in Python: The Complete Guide
The Python ThreadPoolExecutor allows you to create and manage thread pools in Python. Although the ThreadPoolExecutor has been available ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi, thanks for asking! I’m fine waiting for any release train. I’ve pinned the commit hash in my tox.ini 😉
Can you live with master, or do you need a patch release?