Skip to content

Commit

Permalink
test: Allow fake_filesystem to work with TemporaryDirectory (#5035)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealFalcon committed Mar 11, 2024
1 parent 4ece79d commit 94609bc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/unittests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
os: [
("listdir", 1),
("mkdir", 1),
("rmdir", 1),
("lstat", 1),
("symlink", 2),
("stat", 1),
Expand Down Expand Up @@ -55,6 +56,12 @@
@pytest.fixture
def fake_filesystem(mocker, tmpdir):
"""Mocks fs functions to operate under `tmpdir`"""
# This allows fake_filesystem to be used with production code that
# creates temporary directories. Functions like TemporaryDirectory()
# attempt to create a directory under "/tmp" assuming that it already
# exists, but then it fails because of the retargeting that happens here.
tmpdir.mkdir("tmp")

for (mod, funcs) in FS_FUNCS.items():
for f, nargs in funcs:
func = getattr(mod, f)
Expand Down

0 comments on commit 94609bc

Please sign in to comment.