Skip to content

Commit 4284181

Browse files
committed
See what creating the folder for FAKE_DIR_PATH does on Windows
1 parent 304f638 commit 4284181

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/functional/test_files.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import shutil
3+
import sys
34
import tempfile
45

56
import pytest
@@ -298,12 +299,17 @@ def test_add_filepattern_from_dirname_recursive_nofwalk(client, cleanup_pins, mo
298299
def test_add_filepattern_from_dirfd_recursive_nofwalk(client, cleanup_pins, monkeypatch):
299300
monkeypatch.setattr(ipfshttpclient.filescanner, "HAVE_FWALK", False)
300301

301-
with pytest.raises(NotImplementedError):
302-
fd: int = os.open(str(FAKE_DIR_PATH), os.O_RDONLY | O_DIRECTORY)
303-
try:
302+
if sys.platform.startswith("win"):
303+
os.mkdir(FAKE_DIR_PATH)
304+
assert os.path.isdir(FAKE_DIR_PATH)
305+
306+
# On Windows, this line will fail with PermissionError: [Errno 13] Permission denied
307+
fd: int = os.open(str(FAKE_DIR_PATH), os.O_RDONLY | O_DIRECTORY)
308+
try:
309+
with pytest.raises(NotImplementedError):
304310
client.add(fd, pattern=FAKE_DIR_FNPATTERN1, recursive=True)
305-
finally:
306-
os.close(fd)
311+
finally:
312+
os.close(fd)
307313

308314

309315
@pytest.mark.skipif(not ipfshttpclient.filescanner.HAVE_FWALK,

0 commit comments

Comments
 (0)