12
12
import conftest
13
13
14
14
15
- O_DIRECTORY = getattr (os , "O_DIRECTORY" , 0 ) # type: int
15
+ # Windows does not have os.O_DIRECTORY
16
+ O_DIRECTORY : int = getattr (os , "O_DIRECTORY" , 0 )
16
17
17
18
18
19
### test_add_multiple_from_list
@@ -263,15 +264,15 @@ def test_add_filepattern_from_dirname(client, cleanup_pins):
263
264
reason = "No point in disabling os.fwalk if it isn't actually supported" )
264
265
def test_add_filepattern_from_dirname_nofwalk (client , cleanup_pins , monkeypatch ):
265
266
monkeypatch .setattr (ipfshttpclient .filescanner , "HAVE_FWALK" , False )
266
-
267
+
267
268
res = client .add (FAKE_DIR_PATH , pattern = FAKE_DIR_FNPATTERN1 )
268
269
assert conftest .sort_by_key (res ) == conftest .sort_by_key (FAKE_DIR_FNPATTERN1_HASH )
269
270
270
271
271
272
@pytest .mark .skipif (not ipfshttpclient .filescanner .HAVE_FWALK ,
272
273
reason = "Passing directory as file descriptor requires os.fwalk" )
273
274
def test_add_filepattern_from_dirfd (client , cleanup_pins ):
274
- fd = os .open (str (FAKE_DIR_PATH ), os .O_RDONLY | O_DIRECTORY ) # type: int
275
+ fd : int = os .open (str (FAKE_DIR_PATH ), os .O_RDONLY | O_DIRECTORY )
275
276
try :
276
277
res = client .add (fd , pattern = FAKE_DIR_FNPATTERN1 )
277
278
finally :
@@ -288,7 +289,7 @@ def test_add_filepattern_from_dirname_recursive(client, cleanup_pins):
288
289
reason = "No point in disabling os.fwalk if it isn't actually supported" )
289
290
def test_add_filepattern_from_dirname_recursive_nofwalk (client , cleanup_pins , monkeypatch ):
290
291
monkeypatch .setattr (ipfshttpclient .filescanner , "HAVE_FWALK" , False )
291
-
292
+
292
293
res = client .add (FAKE_DIR_PATH , pattern = FAKE_DIR_FNPATTERN1 , recursive = True )
293
294
assert conftest .sort_by_key (res ) == conftest .sort_by_key (FAKE_DIR_FNPATTERN1_RECURSIVE_HASH )
294
295
@@ -297,9 +298,9 @@ def test_add_filepattern_from_dirname_recursive_nofwalk(client, cleanup_pins, mo
297
298
reason = "Opening directory FDs does not work on Windows" )
298
299
def test_add_filepattern_from_dirfd_recursive_nofwalk (client , cleanup_pins , monkeypatch ):
299
300
monkeypatch .setattr (ipfshttpclient .filescanner , "HAVE_FWALK" , False )
300
-
301
+
301
302
with pytest .raises (NotImplementedError ):
302
- fd = os .open (str (FAKE_DIR_PATH ), os .O_RDONLY | O_DIRECTORY ) # type: int
303
+ fd : int = os .open (str (FAKE_DIR_PATH ), os .O_RDONLY | O_DIRECTORY )
303
304
try :
304
305
client .add (fd , pattern = FAKE_DIR_FNPATTERN1 , recursive = True )
305
306
finally :
@@ -309,7 +310,7 @@ def test_add_filepattern_from_dirfd_recursive_nofwalk(client, cleanup_pins, monk
309
310
@pytest .mark .skipif (not ipfshttpclient .filescanner .HAVE_FWALK ,
310
311
reason = "Passing directory as file descriptor requires os.fwalk" )
311
312
def test_add_filepattern_from_dirfd_recursive (client , cleanup_pins ):
312
- fd = os .open (str (FAKE_DIR_PATH ), os .O_RDONLY | O_DIRECTORY ) # type: int
313
+ fd : int = os .open (str (FAKE_DIR_PATH ), os .O_RDONLY | O_DIRECTORY )
313
314
try :
314
315
res = client .add (fd , pattern = FAKE_DIR_FNPATTERN1 , recursive = True )
315
316
finally :
@@ -327,7 +328,7 @@ def test_add_filepattern_from_dirname_recursive_binary(client, cleanup_pins):
327
328
reason = "No point in disabling os.fwalk if it isn't actually supported" )
328
329
def test_add_filepattern_from_dirname_recursive_nofwalk_binary (client , cleanup_pins , monkeypatch ):
329
330
monkeypatch .setattr (ipfshttpclient .filescanner , "HAVE_FWALK" , False )
330
-
331
+
331
332
res = client .add (os .fsencode (str (FAKE_DIR_PATH )),
332
333
pattern = os .fsencode (FAKE_DIR_FNPATTERN1 ), recursive = True )
333
334
assert conftest .sort_by_key (res ) == conftest .sort_by_key (FAKE_DIR_FNPATTERN1_RECURSIVE_HASH )
0 commit comments