Skip to content

Commit cda19c7

Browse files
c0llab0rat0rntninja
authored andcommitted
Narrow scope of exception assertion; document Windows platform guard
1 parent 72ffa18 commit cda19c7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/functional/test_files.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,15 @@ def test_add_filepattern_from_dirname_recursive_nofwalk(client, cleanup_pins, mo
299299
def test_add_filepattern_from_dirfd_recursive_nofwalk(client, cleanup_pins, monkeypatch):
300300
monkeypatch.setattr(ipfshttpclient.filescanner, "HAVE_FWALK", False)
301301

302-
with pytest.raises(NotImplementedError):
303-
fd: int = os.open(str(FAKE_DIR_PATH), os.O_RDONLY | O_DIRECTORY)
304-
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):
305308
client.add(fd, pattern=FAKE_DIR_FNPATTERN1, recursive=True)
306-
finally:
307-
os.close(fd)
309+
finally:
310+
os.close(fd)
308311

309312

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

0 commit comments

Comments
 (0)