Skip to content

Commit 1d9be47

Browse files
committed
Narrow scope of exception assertion; document Windows platform guard
1 parent 5c858b3 commit 1d9be47

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test/functional/test_files.py

Lines changed: 10 additions & 6 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
@@ -293,17 +294,20 @@ def test_add_filepattern_from_dirname_recursive_nofwalk(client, cleanup_pins, mo
293294
assert conftest.sort_by_key(res) == conftest.sort_by_key(FAKE_DIR_FNPATTERN1_RECURSIVE_HASH)
294295

295296

296-
@pytest.mark.skipif(not O_DIRECTORY,
297+
@pytest.mark.skipif(sys.platform.startswith("win"),
297298
reason="Opening directory FDs does not work on Windows")
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+
assert os.path.isdir(FAKE_DIR_PATH)
303+
304+
# On Windows, this line will fail with PermissionError: [Errno 13] Permission denied
305+
fd: int = os.open(str(FAKE_DIR_PATH), os.O_RDONLY | O_DIRECTORY)
306+
try:
307+
with pytest.raises(NotImplementedError):
304308
client.add(fd, pattern=FAKE_DIR_FNPATTERN1, recursive=True)
305-
finally:
306-
os.close(fd)
309+
finally:
310+
os.close(fd)
307311

308312

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

0 commit comments

Comments
 (0)