diff options
author | Xiang Zhang <angwerzx@126.com> | 2018-12-12 12:46:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 12:46:55 (GMT) |
commit | 4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53 (patch) | |
tree | aa3b18ad394fbd5056af5a366e2b4ca6b91d5296 /Lib/test/test_dbm_ndbm.py | |
parent | 5a718e918db6211b633a7afb2bf537eb5b56cb1b (diff) | |
download | cpython-4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53.zip cpython-4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53.tar.gz cpython-4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53.tar.bz2 |
bpo-33106: change dbm key deletion error for readonly file from KeyError to dbm.error (#6295)
Diffstat (limited to 'Lib/test/test_dbm_ndbm.py')
-rw-r--r-- | Lib/test/test_dbm_ndbm.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py index bd411da..7ac75c5 100644 --- a/Lib/test/test_dbm_ndbm.py +++ b/Lib/test/test_dbm_ndbm.py @@ -90,6 +90,17 @@ class DbmTestCase(unittest.TestCase): self.assertEqual(db['Unicode key \U0001f40d'], 'Unicode value \U0001f40d'.encode()) + def test_write_readonly_file(self): + with dbm.ndbm.open(self.filename, 'c') as db: + db[b'bytes key'] = b'bytes value' + with dbm.ndbm.open(self.filename, 'r') as db: + with self.assertRaises(error): + del db[b'not exist key'] + with self.assertRaises(error): + del db[b'bytes key'] + with self.assertRaises(error): + db[b'not exist key'] = b'not exist value' + @unittest.skipUnless(support.TESTFN_NONASCII, 'requires OS support of non-ASCII encodings') def test_nonascii_filename(self): |