MCPcopy Index your code
hub / github.com/python/cpython / test_fd

Method test_fd

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

Source from the content-addressed store, hash-verified

5039 @unittest.skipUnless(os.listdir in os.supports_fd,
5040 'fd support for listdir required for this test.')
5041 def test_fd(self):
5042 self.assertIn(os.scandir, os.supports_fd)
5043 self.create_file('file.txt')
5044 expected_names = ['file.txt']
5045 if os_helper.can_symlink():
5046 os.symlink('file.txt', os.path.join(self.path, 'link'))
5047 expected_names.append('link')
5048
5049 with os_helper.open_dir_fd(self.path) as fd:
5050 with os.scandir(fd) as it:
5051 entries = list(it)
5052 names = [entry.name for entry in entries]
5053 self.assertEqual(sorted(names), expected_names)
5054 self.assertEqual(names, os.listdir(fd))
5055 for entry in entries:
5056 self.assertEqual(entry.path, entry.name)
5057 self.assertEqual(os.fspath(entry), entry.name)
5058 self.assertEqual(entry.is_symlink(), entry.name == 'link')
5059 if os.stat in os.supports_dir_fd:
5060 st = os.stat(entry.name, dir_fd=fd)
5061 self.assertEqual(entry.stat(), st)
5062 st = os.stat(entry.name, dir_fd=fd, follow_symlinks=False)
5063 self.assertEqual(entry.stat(follow_symlinks=False), st)
5064
5065 @unittest.skipIf(support.is_wasi, "WASI maps '' to cwd")
5066 def test_empty_path(self):

Callers

nothing calls this directly

Calls 10

create_fileMethod · 0.95
listClass · 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