[Bug #802128] Make the mode argument of dumbdbm actually work the way it's

described, and add a test for it.

2.5 bugfix candidate, maybe; arguably this patch changes the API of
dumbdbm and shouldn't be added in a point-release.
This commit is contained in:
Andrew M. Kuchling 2006-12-22 15:04:45 +00:00
parent b29069d6b6
commit dc26758ffe
2 changed files with 23 additions and 3 deletions

View file

@ -38,6 +38,20 @@ 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'):
return
f = dumbdbm.open(_fname, 'c', 0632)
f.close()
import stat
st = os.stat(_fname + '.dat')
self.assertEqual(stat.S_IMODE(st.st_mode), 0632)
st = os.stat(_fname + '.dir')
self.assertEqual(stat.S_IMODE(st.st_mode), 0632)
def test_close_twice(self):
f = dumbdbm.open(_fname)
f['a'] = 'b'