(self)
| 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): |
nothing calls this directly
no test coverage detected