MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_fd

Method test_fd

Lib/test/test_os.py:5317–5339  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5315 @unittest.skipUnless(os.listdir in os.supports_fd,
5316 'fd support for listdir required for this test.')
5317 def test_fd(self):
5318 self.assertIn(os.scandir, os.supports_fd)
5319 self.create_file('file.txt')
5320 expected_names = ['file.txt']
5321 if os_helper.can_symlink():
5322 os.symlink('file.txt', os.path.join(self.path, 'link'))
5323 expected_names.append('link')
5324
5325 with os_helper.open_dir_fd(self.path) as fd:
5326 with os.scandir(fd) as it:
5327 entries = list(it)
5328 names = [entry.name for entry in entries]
5329 self.assertEqual(sorted(names), expected_names)
5330 self.assertEqual(names, os.listdir(fd))
5331 for entry in entries:
5332 self.assertEqual(entry.path, entry.name)
5333 self.assertEqual(os.fspath(entry), entry.name)
5334 self.assertEqual(entry.is_symlink(), entry.name == 'link')
5335 if os.stat in os.supports_dir_fd:
5336 st = os.stat(entry.name, dir_fd=fd)
5337 self.assertEqual(entry.stat(), st)
5338 st = os.stat(entry.name, dir_fd=fd, follow_symlinks=False)
5339 self.assertEqual(entry.stat(follow_symlinks=False), st)
5340
5341 @unittest.skipIf(support.is_wasi, "WASI maps '' to cwd")
5342 def test_empty_path(self):

Callers

nothing calls this directly

Calls 11

create_fileMethod · 0.95
listClass · 0.85
sortedFunction · 0.85
assertInMethod · 0.80
listdirMethod · 0.80
joinMethod · 0.45
appendMethod · 0.45
scandirMethod · 0.45
assertEqualMethod · 0.45
is_symlinkMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected