Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.11 test failures (IsADirectoryError) with 4.6.0 #686

Closed
mgorny opened this issue Jul 13, 2022 · 6 comments · Fixed by #688
Closed

Python 3.11 test failures (IsADirectoryError) with 4.6.0 #686

mgorny opened this issue Jul 13, 2022 · 6 comments · Fixed by #688
Labels

Comments

@mgorny
Copy link
Contributor

mgorny commented Jul 13, 2022

Describe the bug
The 4.6.0 declares support for py3.11. However, when running the test suite I get a bunch of failures (they seem to boil down to IsADirectoryError being raised):

Test failures
======================================================================
ERROR: test_named_temporary_file (pyfakefs.tests.fake_tempfile_test.FakeTempfileModuleTest.test_named_temporary_file)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_tempfile_test.py", line 34, in test_named_temporary_file
    obj = tempfile.NamedTemporaryFile()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
ERROR: test_named_temporary_file_no_delete (pyfakefs.tests.fake_tempfile_test.FakeTempfileModuleTest.test_named_temporary_file_no_delete)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_tempfile_test.py", line 41, in test_named_temporary_file_no_delete
    obj = tempfile.NamedTemporaryFile(delete=False)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
ERROR: test_temporary_file (pyfakefs.tests.fake_tempfile_test.FakeTempfileModuleTest.test_temporary_file)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_tempfile_test.py", line 101, in test_temporary_file
    with tempfile.TemporaryFile() as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 657, in TemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
ERROR: test_pause_resume (pyfakefs.tests.fake_filesystem_unittest_test.PauseResumePatcherTest.test_pause_resume)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_filesystem_unittest_test.py", line 623, in test_pause_resume
    fake_temp_file = tempfile.NamedTemporaryFile()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
ERROR: test_pause_resume_contextmanager (pyfakefs.tests.fake_filesystem_unittest_test.PauseResumePatcherTest.test_pause_resume_contextmanager)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_filesystem_unittest_test.py", line 639, in test_pause_resume_contextmanager
    fake_temp_file = tempfile.NamedTemporaryFile()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
ERROR: test_pause_resume (pyfakefs.tests.fake_filesystem_unittest_test.PauseResumeTest.test_pause_resume)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_filesystem_unittest_test.py", line 554, in test_pause_resume
    fake_temp_file = tempfile.NamedTemporaryFile()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
ERROR: test_pause_resume_contextmanager (pyfakefs.tests.fake_filesystem_unittest_test.PauseResumeTest.test_pause_resume_contextmanager)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_filesystem_unittest_test.py", line 589, in test_pause_resume_contextmanager
    fake_temp_file = tempfile.NamedTemporaryFile()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
ERROR: test_pause_resume_fs (pyfakefs.tests.fake_filesystem_unittest_test.PauseResumeTest.test_pause_resume_fs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_filesystem_unittest_test.py", line 568, in test_pause_resume_fs
    fake_temp_file = tempfile.NamedTemporaryFile()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
ERROR: test_pause_resume_fs_contextmanager (pyfakefs.tests.fake_filesystem_unittest_test.PauseResumeTest.test_pause_resume_fs_contextmanager)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_filesystem_unittest_test.py", line 602, in test_pause_resume_fs_contextmanager
    fake_temp_file = tempfile.NamedTemporaryFile()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
ERROR: test_write_excel (pyfakefs.tests.patched_packages_test.TestPatchedPackages.test_write_excel)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/patched_packages_test.py", line 70, in test_write_excel
    with pd.ExcelWriter(path) as writer:
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/pandas/io/excel/_base.py", line 1201, in __exit__
    self.close()
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/pandas/io/excel/_base.py", line 1205, in close
    self.save()
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/pandas/io/excel/_openpyxl.py", line 81, in save
    self.book.save(self.handles.handle)
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/openpyxl/workbook/workbook.py", line 407, in save
    save_workbook(self, filename)
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/openpyxl/writer/excel.py", line 293, in save_workbook
    writer.save()
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/openpyxl/writer/excel.py", line 275, in save
    self.write_data()
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/openpyxl/writer/excel.py", line 75, in write_data
    self._write_worksheets()
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/openpyxl/writer/excel.py", line 215, in _write_worksheets
    self.write_worksheet(ws)
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/openpyxl/writer/excel.py", line 199, in write_worksheet
    writer = WorksheetWriter(ws)
             ^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/openpyxl/worksheet/_writer.py", line 52, in __init__
    out = create_temporary_file()
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/.tox/py311/lib/python3.11/site-packages/openpyxl/worksheet/_writer.py", line 36, in create_temporary_file
    fobj = NamedTemporaryFile(mode='w+', suffix=suffix,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5009, in open
    return fake_open(file, mode, buffering, encoding, errors,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5694, in __call__
    return self.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5772, in call
    file_object = self._init_file_object(file_object,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 5828, in _init_file_object
    file_object.set_contents('')
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 675, in set_contents
    raise self.filesystem.raise_os_error(errno.EISDIR, self.path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pyfakefs-4.6.0/pyfakefs/fake_filesystem.py", line 1098, in raise_os_error
    raise OSError(err_no, message, filename)
IsADirectoryError: [Errno 21] Is a directory in the fake filesystem: '/tmp'

======================================================================
FAIL: test_temporay_file_with_dir (pyfakefs.tests.fake_tempfile_test.FakeTempfileModuleTest.test_temporay_file_with_dir)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs-4.6.0/pyfakefs/tests/fake_tempfile_test.py", line 107, in test_temporay_file_with_dir
    with self.assertRaises(FileNotFoundError):
AssertionError: FileNotFoundError not raised

----------------------------------------------------------------------
Ran 2064 tests in 8.078s

FAILED (failures=1, errors=10, skipped=842, expected failures=2)

How To Reproduce
tox -e py311

Your environment
Please run the following and paste the output.

$ python -c "import platform; print(platform.platform())"
Linux-5.18.10-gentoo-dist-x86_64-AMD_Ryzen_5_3600_6-Core_Processor-with-glibc2.35
$ python -c "import sys; print('Python', sys.version)"
Python 3.11.0b4 (main, Jul 13 2022, 07:09:35) [GCC 12.1.1 20220709]
$ python -c "from pyfakefs.fake_filesystem import __version__; print('pyfakefs', __version__)"
pyfakefs 4.6.0
@mrbean-bremen
Copy link
Member

Thanks for the report. Maybe it was premature to claim support for Python 3.11, given that it is not released yet.
We rely solely on the CI tests here, which are running under Ubuntu for the Linux tests. It looks like NamedTemporaryFile behaves differently under gentoo and Ubuntu, or something else is different in the test environment. At a cursory glance it seems that the tempfile created by NamedTemporaryFile returns the root path tmp instead of the file path (in the fake file system), but right now I have no idea what could cause that.

I will have a closer tonight or tomorrow, maybe I'll find some Python 3.11 changes in tmpfile that may cause this.

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Jul 13, 2022

While this is not fixed, you probably have to pin pyfakefs to a version < 4.6.0 (though that would not support 3.11 at all).

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Jul 13, 2022

Ok, turns out that error now also appears in the same CI tests that passed yesterday, on all systems. Yesterday's builds have used Python 3.11 beta 3, while today's use 3.11 beta 4, which has been released a day before. Obviously something has changed in tempfile in this version, that is not compatible with pyfakefs (or much less likely, a bug in Python).

Hopefully I can reproduce this locally once I have installed the new version...

@mrbean-bremen
Copy link
Member

Update: this is indeed missing functionality in pyfakefs. In open, the opener argument has been ignored so far, which is now used by tempfile. I think I can make a quick fix - the usages in tempfile serving as a test for the time being - and put out a patch release ASAP.

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Jul 13, 2022
- needed to support tempfile in Python 3.11
- fixes pytest-dev#686
mrbean-bremen added a commit that referenced this issue Jul 13, 2022
- needed to support tempfile in Python 3.11
- fixes #686
github-actions bot pushed a commit that referenced this issue Jul 13, 2022
@mgorny
Copy link
Contributor Author

mgorny commented Jul 13, 2022

Thanks!

@mrbean-bremen
Copy link
Member

I put out a new Pypi patch release (4.6.1).

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Jul 14, 2022
- the wrong argument had been passed
- fixes pytest-dev#686
flowerhack added a commit to flowerhack/clusterfuzz that referenced this issue May 18, 2023
When running the unit tests locally, test_minijail_env_vars fails with
an IsADirectoryError (Is a directory in the fake filesystem: '/tmp').

It looks as if this is an issue with pyfakefs misbehaving on certain
platforms in newer versions of Python: pytest-dev/pyfakefs#686

By updating the pipfile to a newer version of pyfakefs, the unit test
now passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants