mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-33106: change dbm key deletion error for readonly file from KeyError to dbm.error (#6295)
This commit is contained in:
parent
5a718e918d
commit
4fb0b8bc25
9 changed files with 57 additions and 9 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue