gh-113086: Add tests for os.chmod() and os.lchmod() (GH-113087)

Also make test_copymode_symlink_to_symlink in test_shutil more strict.
This commit is contained in:
Serhiy Storchaka 2023-12-14 09:16:06 +02:00 committed by GitHub
parent fddc829236
commit b4f2c89118
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 118 additions and 1 deletions

View file

@ -1132,10 +1132,11 @@ class TestCopy(BaseTest, unittest.TestCase):
os.lchmod(src_link, stat.S_IRWXO|stat.S_IRWXG)
# link to link
os.lchmod(dst_link, stat.S_IRWXO)
old_mode = os.stat(dst).st_mode
shutil.copymode(src_link, dst_link, follow_symlinks=False)
self.assertEqual(os.lstat(src_link).st_mode,
os.lstat(dst_link).st_mode)
self.assertNotEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
self.assertEqual(os.stat(dst).st_mode, old_mode)
# src link - use chmod
os.lchmod(dst_link, stat.S_IRWXO)
shutil.copymode(src_link, dst, follow_symlinks=False)