mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
[Bug #802128 continued] Modify mode depending on the process umask.
Is there really no other way to read the umask than to set it? Hope this works on Windows...
This commit is contained in:
parent
dc26758ffe
commit
9ef0ef5b72
2 changed files with 21 additions and 6 deletions
|
@ -40,17 +40,21 @@ class DumbDBMTestCase(unittest.TestCase):
|
|||
|
||||
def test_dumbdbm_creation_mode(self):
|
||||
# On platforms without chmod, don't do anything.
|
||||
if not hasattr(os, 'chmod'):
|
||||
if not (hasattr(os, 'chmod') and hasattr(os, 'umask')):
|
||||
return
|
||||
|
||||
f = dumbdbm.open(_fname, 'c', 0632)
|
||||
f.close()
|
||||
|
||||
try:
|
||||
old_umask = os.umask(0002)
|
||||
f = dumbdbm.open(_fname, 'c', 0637)
|
||||
f.close()
|
||||
finally:
|
||||
os.umask(old_umask)
|
||||
|
||||
import stat
|
||||
st = os.stat(_fname + '.dat')
|
||||
self.assertEqual(stat.S_IMODE(st.st_mode), 0632)
|
||||
self.assertEqual(stat.S_IMODE(st.st_mode), 0635)
|
||||
st = os.stat(_fname + '.dir')
|
||||
self.assertEqual(stat.S_IMODE(st.st_mode), 0632)
|
||||
self.assertEqual(stat.S_IMODE(st.st_mode), 0635)
|
||||
|
||||
def test_close_twice(self):
|
||||
f = dumbdbm.open(_fname)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue