(self)
| 2315 | os.chown("file", 0, 0, dir_fd=0) |
| 2316 | |
| 2317 | def test_link(self): |
| 2318 | self._verify_available("HAVE_LINKAT") |
| 2319 | if self.mac_ver >= (10, 10): |
| 2320 | self.assertIn("HAVE_LINKAT", posix._have_functions) |
| 2321 | |
| 2322 | else: |
| 2323 | self.assertNotIn("HAVE_LINKAT", posix._have_functions) |
| 2324 | |
| 2325 | with self.assertRaisesRegex(NotImplementedError, "src_dir_fd unavailable"): |
| 2326 | os.link("source", "target", src_dir_fd=0) |
| 2327 | |
| 2328 | with self.assertRaisesRegex(NotImplementedError, "dst_dir_fd unavailable"): |
| 2329 | os.link("source", "target", dst_dir_fd=0) |
| 2330 | |
| 2331 | with self.assertRaisesRegex(NotImplementedError, "src_dir_fd unavailable"): |
| 2332 | os.link("source", "target", src_dir_fd=0, dst_dir_fd=0) |
| 2333 | |
| 2334 | # issue 41355: !HAVE_LINKAT code path ignores the follow_symlinks flag |
| 2335 | with os_helper.temp_dir() as base_path: |
| 2336 | link_path = os.path.join(base_path, "link") |
| 2337 | target_path = os.path.join(base_path, "target") |
| 2338 | source_path = os.path.join(base_path, "source") |
| 2339 | |
| 2340 | with open(source_path, "w") as fp: |
| 2341 | fp.write("data") |
| 2342 | |
| 2343 | os.symlink("target", link_path) |
| 2344 | |
| 2345 | # Calling os.link should fail in the link(2) call, and |
| 2346 | # should not reject *follow_symlinks* (to match the |
| 2347 | # behaviour you'd get when building on a platform without |
| 2348 | # linkat) |
| 2349 | with self.assertRaises(FileExistsError): |
| 2350 | os.link(source_path, link_path, follow_symlinks=True) |
| 2351 | |
| 2352 | with self.assertRaises(FileExistsError): |
| 2353 | os.link(source_path, link_path, follow_symlinks=False) |
| 2354 | |
| 2355 | |
| 2356 | def test_listdir_scandir(self): |
nothing calls this directly
no test coverage detected