summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dumbdbm.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_dumbdbm.py')
-rw-r--r--Lib/test/test_dumbdbm.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_dumbdbm.py b/Lib/test/test_dumbdbm.py
index 63b14b0..e5dfe1d 100644
--- a/Lib/test/test_dumbdbm.py
+++ b/Lib/test/test_dumbdbm.py
@@ -38,6 +38,24 @@ class DumbDBMTestCase(unittest.TestCase):
self.read_helper(f)
f.close()
+ def test_dumbdbm_creation_mode(self):
+ # On platforms without chmod, don't do anything.
+ if not (hasattr(os, 'chmod') and hasattr(os, 'umask')):
+ return
+
+ 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), 0635)
+ st = os.stat(_fname + '.dir')
+ self.assertEqual(stat.S_IMODE(st.st_mode), 0635)
+
def test_close_twice(self):
f = dumbdbm.open(_fname)
f['a'] = 'b'