diff options
| author | Barry Warsaw <barry@python.org> | 2012-06-04 13:41:48 (GMT) |
|---|---|---|
| committer | Barry Warsaw <barry@python.org> | 2012-06-04 13:41:48 (GMT) |
| commit | c58c392da7f8fb49b84b2f4de35d3c40ed6d36c1 (patch) | |
| tree | a574ea8bd98e1d8d3be264c68b9952bda33b18c6 /Lib/test/test_os.py | |
| parent | 409da157d7ff2a49892e20a94a3fc83475845d22 (diff) | |
| parent | bcd304480f16f3f936a7bdbff4dfab41f8e30292 (diff) | |
| download | cpython-c58c392da7f8fb49b84b2f4de35d3c40ed6d36c1.zip cpython-c58c392da7f8fb49b84b2f4de35d3c40ed6d36c1.tar.gz cpython-c58c392da7f8fb49b84b2f4de35d3c40ed6d36c1.tar.bz2 | |
Trunk merge.
Diffstat (limited to 'Lib/test/test_os.py')
| -rw-r--r-- | Lib/test/test_os.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 9b29b37..3ee5a1e 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -838,6 +838,31 @@ class MakedirTests(unittest.TestCase): os.makedirs(path, mode=mode, exist_ok=True) os.umask(old_mask) + def test_exist_ok_s_isgid_directory(self): + path = os.path.join(support.TESTFN, 'dir1') + S_ISGID = stat.S_ISGID + mode = 0o777 + old_mask = os.umask(0o022) + try: + existing_testfn_mode = stat.S_IMODE( + os.lstat(support.TESTFN).st_mode) + os.chmod(support.TESTFN, existing_testfn_mode | S_ISGID) + if (os.lstat(support.TESTFN).st_mode & S_ISGID != S_ISGID): + raise unittest.SkipTest('No support for S_ISGID dir mode.') + # The os should apply S_ISGID from the parent dir for us, but + # this test need not depend on that behavior. Be explicit. + os.makedirs(path, mode | S_ISGID) + # http://bugs.python.org/issue14992 + # Should not fail when the bit is already set. + os.makedirs(path, mode, exist_ok=True) + # remove the bit. + os.chmod(path, stat.S_IMODE(os.lstat(path).st_mode) & ~S_ISGID) + with self.assertRaises(OSError): + # Should fail when the bit is not already set when demanded. + os.makedirs(path, mode | S_ISGID, exist_ok=True) + finally: + os.umask(old_mask) + def test_exist_ok_existing_regular_file(self): base = support.TESTFN path = os.path.join(support.TESTFN, 'dir1') |
