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