diff options
| author | Xiang Zhang <angwerzx@126.com> | 2018-12-12 20:46:55 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-12 20:46:55 +0800 |
| commit | 4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53 (patch) | |
| tree | aa3b18ad394fbd5056af5a366e2b4ca6b91d5296 /Lib/test/test_dbm_gnu.py | |
| parent | 5a718e918db6211b633a7afb2bf537eb5b56cb1b (diff) | |
| download | cpython-git-4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53.tar.gz | |
bpo-33106: change dbm key deletion error for readonly file from KeyError to dbm.error (#6295)
Diffstat (limited to 'Lib/test/test_dbm_gnu.py')
| -rw-r--r-- | Lib/test/test_dbm_gnu.py | 11 |
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): |
