-
Notifications
You must be signed in to change notification settings - Fork 93
Closed
Labels
Description
Describe the bug
When pyfakefs is loaded via the pytest plugin on Python 3.13.0 beta 1, I'm seeing crashes.
Note
I've confirmed this behavior with pyfakefs 5.5.0, 5.4.1, and 5.3.0, and with pytest 8.2.0 and 8.0.0.
However, this does not happen with Python 3.12.
It appears that this is specific to Python 3.13.0 beta 1.
========================================================= test session starts =========================================================
platform linux -- Python 3.13.0b1, pytest-8.2.0, pluggy-1.5.0
rootdir: /home/kurt/dev/test
configfile: pyproject.toml
plugins: pyfakefs-5.5.0
collected 1 item
test_demo.py E [100%]Traceback (most recent call last):
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_filesystem.py", line 1678, in get_object_from_normpath
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_file.py", line 562, in get_entry
KeyError: 'home'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 178, in main
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pluggy/_hooks.py", line 513, in __call__
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pluggy/_manager.py", line 120, in _hookexec
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 139, in _multicall
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 103, in _multicall
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/_pytest/main.py", line 332, in pytest_cmdline_main
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/_pytest/main.py", line 317, in wrap_session
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_os.py", line 1426, in wrapped
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_os.py", line 456, in chdir
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_filesystem.py", line 2940, in confirmdir
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_filesystem.py", line 1760, in resolve
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_filesystem.py", line 1689, in get_object_from_normpath
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_filesystem.py", line 430, in raise_os_error
FileNotFoundError: [Errno 2] No such file or directory in the fake filesystem: '/home/kurt/dev/test'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/kurt/dev/test/.venv/bin/pytest", line 8, in <module>
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 206, in console_main
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 186, in main
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1135, in _ensure_unconfigure
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pluggy/_hooks.py", line 513, in __call__
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pluggy/_manager.py", line 120, in _hookexec
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 139, in _multicall
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 103, in _multicall
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/_pytest/faulthandler.py", line 45, in pytest_unconfigure
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_os.py", line 1426, in wrapped
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_os.py", line 326, in close
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_filesystem.py", line 885, in get_open_file
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_filesystem.py", line 907, in get_open_files
File "/home/kurt/dev/test/.venv/lib/python3.13/site-packages/pyfakefs/fake_filesystem.py", line 430, in raise_os_error
OSError: [Errno 9] Bad file descriptor in the fake filesystem: '9'
How To Reproduce
Create a file named test_demo.py
with these contents:
def test_pyfakefs(fs):
pass
Create a virtual environment using Python 3.13:
$ python3.13 -m venv .venv
$ source .venv/bin/activate
$ pip install pytest pyfakefs
$
$ # At the time of writing, these packages are installed:
$ pip freeze
iniconfig==2.0.0
packaging==24.0
pluggy==1.5.0
pyfakefs==5.5.0
pytest==8.2.0
Then, run this command to see the failure:
pytest test_demo.py
Your environment
With the virtual environment (created using the steps above) activated, here are the OS/Python/pyfakefs/pytest versions installed:
Linux-6.5.0-28-generic-x86_64-with-glibc2.35
Python 3.13.0b1 (main, May 9 2024, 19:41:45) [GCC 11.4.0]
pyfakefs 5.5.0
pytest 8.2.0
hugovk and jaraco