summaryrefslogtreecommitdiff
path: root/Lib/test/test_dbm_gnu.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_dbm_gnu.py')
-rw-r--r--Lib/test/test_dbm_gnu.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py
index 16b7fe6fac..f1c7d34085 100644
--- a/Lib/test/test_dbm_gnu.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -131,6 +131,17 @@ class TestGdbm(unittest.TestCase):
self.assertEqual(db['Unicode key \U0001f40d'],
'Unicode value \U0001f40d'.encode())
+ def test_write_readonly_file(self):
+ with gdbm.open(filename, 'c') as db:
+ db[b'bytes key'] = b'bytes value'
+ with gdbm.open(filename, 'r') as db:
+ with self.assertRaises(gdbm.error):
+ del db[b'not exist key']
+ with self.assertRaises(gdbm.error):
+ del db[b'bytes key']
+ with self.assertRaises(gdbm.error):
+ db[b'not exist key'] = b'not exist value'
+
@unittest.skipUnless(TESTFN_NONASCII,
'requires OS support of non-ASCII encodings')
def test_nonascii_filename(self):