(self)
| 2405 | os.chown("file", 0, 0, dir_fd=0) |
| 2406 | |
| 2407 | def test_link(self): |
| 2408 | self._verify_available("HAVE_LINKAT") |
| 2409 | if self.mac_ver >= (10, 10): |
| 2410 | self.assertIn("HAVE_LINKAT", posix._have_functions) |
| 2411 | |
| 2412 | else: |
| 2413 | self.assertNotIn("HAVE_LINKAT", posix._have_functions) |
| 2414 | |
| 2415 | with self.assertRaisesRegex(NotImplementedError, "src_dir_fd unavailable"): |
| 2416 | os.link("source", "target", src_dir_fd=0) |
| 2417 | |
| 2418 | with self.assertRaisesRegex(NotImplementedError, "dst_dir_fd unavailable"): |
| 2419 | os.link("source", "target", dst_dir_fd=0) |
| 2420 | |
| 2421 | with self.assertRaisesRegex(NotImplementedError, "src_dir_fd unavailable"): |
| 2422 | os.link("source", "target", src_dir_fd=0, dst_dir_fd=0) |
| 2423 | |
| 2424 | # issue 41355: !HAVE_LINKAT code path ignores the follow_symlinks flag |
| 2425 | with os_helper.temp_dir() as base_path: |
| 2426 | link_path = os.path.join(base_path, "link") |
| 2427 | target_path = os.path.join(base_path, "target") |
| 2428 | source_path = os.path.join(base_path, "source") |
| 2429 | |
| 2430 | with open(source_path, "w") as fp: |
| 2431 | fp.write("data") |
| 2432 | |
| 2433 | os.symlink("target", link_path) |
| 2434 | |
| 2435 | # Calling os.link should fail in the link(2) call, and |
| 2436 | # should not reject *follow_symlinks* (to match the |
| 2437 | # behaviour you'd get when building on a platform without |
| 2438 | # linkat) |
| 2439 | with self.assertRaises(FileExistsError): |
| 2440 | os.link(source_path, link_path, follow_symlinks=True) |
| 2441 | |
| 2442 | with self.assertRaises(FileExistsError): |
| 2443 | os.link(source_path, link_path, follow_symlinks=False) |
| 2444 | |
| 2445 | |
| 2446 | def test_listdir_scandir(self): |
nothing calls this directly
no test coverage detected