Closed Aran-Fey closed 1 month ago
Describe the bug Files that only exist on the fake file system cannot be imported, neither with a regular import statement nor via importlib.
import
importlib
How To Reproduce
import pytest import importlib.util import sys from pathlib import Path def test_import(fs): module_path = Path('heya.py') module_path.write_text('x = 1234') spec = importlib.util.spec_from_file_location('heya', module_path) module = importlib.util.module_from_spec(spec) sys.modules['heya'] = module spec.loader.exec_module(module) # Crashes with FileNotFoundError if __name__ == '__main__': pytest.main([__file__])
Your environment
Windows-11-10.0.22631-SP0 Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] pyfakefs 5.7.1 pytest 7.3.2
Describe the bug Files that only exist on the fake file system cannot be imported, neither with a regular
import
statement nor viaimportlib
.How To Reproduce
Your environment
Windows-11-10.0.22631-SP0 Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] pyfakefs 5.7.1 pytest 7.3.2