Skip to content

Commit

Permalink
pythongh-117127: glob tests: Reopen dir_fd to pick up directory chang…
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou authored Mar 22, 2024
1 parent 8383915 commit 42ae924
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Lib/test/test_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def setUp(self):
os.symlink(self.norm('broken'), self.norm('sym1'))
os.symlink('broken', self.norm('sym2'))
os.symlink(os.path.join('a', 'bcd'), self.norm('sym3'))
self.open_dirfd()

def open_dirfd(self):
if self.dir_fd is not None:
os.close(self.dir_fd)
if {os.open, os.stat} <= os.supports_dir_fd and os.scandir in os.supports_fd:
self.dir_fd = os.open(self.tempdir, os.O_RDONLY | os.O_DIRECTORY)
else:
Expand Down Expand Up @@ -350,6 +355,10 @@ def test_glob_non_directory(self):
def test_glob_named_pipe(self):
path = os.path.join(self.tempdir, 'mypipe')
os.mkfifo(path)

# gh-117127: Reopen self.dir_fd to pick up directory changes
self.open_dirfd()

self.assertEqual(self.rglob('mypipe'), [path])
self.assertEqual(self.rglob('mypipe*'), [path])
self.assertEqual(self.rglob('mypipe', ''), [])
Expand Down

0 comments on commit 42ae924

Please sign in to comment.