diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2006-12-22 15:16:58 +0000 |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2006-12-22 15:16:58 +0000 |
commit | 9ef0ef5b729b88491be1d28ab46248b645645c44 (patch) | |
tree | b75b22ab777b177152ebc54dd9f490cf6414b706 /Lib/test/test_dumbdbm.py | |
parent | dc26758ffeb33f6d59cb30b0019da9252e0cea1c (diff) | |
download | cpython-git-9ef0ef5b729b88491be1d28ab46248b645645c44.tar.gz |
[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...
Diffstat (limited to 'Lib/test/test_dumbdbm.py')
-rw-r--r-- | Lib/test/test_dumbdbm.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/test/test_dumbdbm.py b/Lib/test/test_dumbdbm.py index a1e34da34b..e5dfe1d7e7 100644 --- a/Lib/test/test_dumbdbm.py +++ b/Lib/test/test_dumbdbm.py @@ -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) |