@@ -40,6 +40,11 @@ def setUp(self):
40
40
os .symlink (self .norm ('broken' ), self .norm ('sym1' ))
41
41
os .symlink ('broken' , self .norm ('sym2' ))
42
42
os .symlink (os .path .join ('a' , 'bcd' ), self .norm ('sym3' ))
43
+ self .open_dirfd ()
44
+
45
+ def open_dirfd (self ):
46
+ if self .dir_fd is not None :
47
+ os .close (self .dir_fd )
43
48
if {os .open , os .stat } <= os .supports_dir_fd and os .scandir in os .supports_fd :
44
49
self .dir_fd = os .open (self .tempdir , os .O_RDONLY | os .O_DIRECTORY )
45
50
else :
@@ -332,6 +337,33 @@ def test_recursive_glob(self):
332
337
eq (glob .glob ('**' , recursive = True , include_hidden = True ),
333
338
[join (* i ) for i in full + rec ])
334
339
340
+ def test_glob_non_directory (self ):
341
+ eq = self .assertSequencesEqual_noorder
342
+ eq (self .rglob ('EF' ), self .joins (('EF' ,)))
343
+ eq (self .rglob ('EF' , '' ), [])
344
+ eq (self .rglob ('EF' , '*' ), [])
345
+ eq (self .rglob ('EF' , '**' ), [])
346
+ eq (self .rglob ('nonexistent' ), [])
347
+ eq (self .rglob ('nonexistent' , '' ), [])
348
+ eq (self .rglob ('nonexistent' , '*' ), [])
349
+ eq (self .rglob ('nonexistent' , '**' ), [])
350
+
351
+ @unittest .skipUnless (hasattr (os , "mkfifo" ), 'requires os.mkfifo()' )
352
+ @unittest .skipIf (sys .platform == "vxworks" ,
353
+ "fifo requires special path on VxWorks" )
354
+ def test_glob_named_pipe (self ):
355
+ path = os .path .join (self .tempdir , 'mypipe' )
356
+ os .mkfifo (path )
357
+
358
+ # gh-117127: Reopen self.dir_fd to pick up directory changes
359
+ self .open_dirfd ()
360
+
361
+ self .assertEqual (self .rglob ('mypipe' ), [path ])
362
+ self .assertEqual (self .rglob ('mypipe*' ), [path ])
363
+ self .assertEqual (self .rglob ('mypipe' , '' ), [])
364
+ self .assertEqual (self .rglob ('mypipe' , 'sub' ), [])
365
+ self .assertEqual (self .rglob ('mypipe' , '*' ), [])
366
+
335
367
def test_glob_many_open_files (self ):
336
368
depth = 30
337
369
base = os .path .join (self .tempdir , 'deep' )
0 commit comments