diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-07 08:56:39 (GMT) |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-07 08:56:39 (GMT) |
| commit | 028ace1ccbabd40f6491b0337054a341be47a39d (patch) | |
| tree | 8a404a9628b4ad565eaa49d2669f57b1b5c635e1 /Lib/test/test_dbm_dumb.py | |
| parent | e5031260741e18968faedd19c2ac617ddc8f5c32 (diff) | |
| download | cpython-028ace1ccbabd40f6491b0337054a341be47a39d.zip cpython-028ace1ccbabd40f6491b0337054a341be47a39d.tar.gz cpython-028ace1ccbabd40f6491b0337054a341be47a39d.tar.bz2 | |
Issue #28847: dbm.dumb now supports reading read-only files and no longer
writes the index file when it is not changed.
Diffstat (limited to 'Lib/test/test_dbm_dumb.py')
| -rw-r--r-- | Lib/test/test_dbm_dumb.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py index ff63c88..235ab11 100644 --- a/Lib/test/test_dbm_dumb.py +++ b/Lib/test/test_dbm_dumb.py @@ -5,6 +5,7 @@ import io import operator import os +import stat import unittest import dbm.dumb as dumbdbm from test import support @@ -234,6 +235,21 @@ class DumbDBMTestCase(unittest.TestCase): pass self.assertEqual(stdout.getvalue(), '') + @unittest.skipUnless(hasattr(os, 'chmod'), 'test needs os.chmod()') + def test_readonly_files(self): + with support.temp_dir() as dir: + fname = os.path.join(dir, 'db') + with dumbdbm.open(fname, 'n') as f: + self.assertEqual(list(f.keys()), []) + for key in self._dict: + f[key] = self._dict[key] + os.chmod(fname + ".dir", stat.S_IRUSR) + os.chmod(fname + ".dat", stat.S_IRUSR) + os.chmod(dir, stat.S_IRUSR|stat.S_IXUSR) + with dumbdbm.open(fname, 'r') as f: + self.assertEqual(sorted(f.keys()), sorted(self._dict)) + f.close() # don't write + def tearDown(self): _delete_files() |
