Skip to content

Different ids for FakeOsModule.<some> Python3.12 #1171

Open
@evgenii-moriakhin

Description

@evgenii-moriakhin

On Python3.12 (python:3.12-alpine)

import shutil
from unittest.mock import patch

from pyfakefs.fake_filesystem import FakeFilesystem
from pyfakefs.fake_os import FakeOsModule

fake_fs = FakeFilesystem()
os_mock = FakeOsModule(fake_fs)

for _ in range(10):
    print(id(os_mock.lstat))

with patch("shutil.os", os_mock):
    shutil.rmtree("/foo")

prints (sometimes) different ids and raised

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/local/lib/python3.12/shutil.py", line 759, in rmtree
    _rmtree_safe_fd(stack, onexc)
  File "/usr/local/lib/python3.12/shutil.py", line 667, in _rmtree_safe_fd
    assert func is os.lstat
           ^^^^^^^^^^^^^^^^
AssertionError

I don't understand what this is related to, why different id's are returned for class

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions