diff options
author | Raymond Hettinger <python@rcn.com> | 2008-07-25 18:43:33 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-07-25 18:43:33 (GMT) |
commit | 8c664e8628ace6a9f3b64980af262b67cd7f3e59 (patch) | |
tree | a020e103bacd0b2b9cc9f464f73454e23655abb8 /Lib/test/test_shelve.py | |
parent | 4982d5d04acff706cd43c77e757c0121a14a0c8d (diff) | |
download | cpython-8c664e8628ace6a9f3b64980af262b67cd7f3e59.zip cpython-8c664e8628ace6a9f3b64980af262b67cd7f3e59.tar.gz cpython-8c664e8628ace6a9f3b64980af262b67cd7f3e59.tar.bz2 |
Issue 1592: Better error reporting for operations on closed shelves.
Diffstat (limited to 'Lib/test/test_shelve.py')
-rw-r--r-- | Lib/test/test_shelve.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_shelve.py b/Lib/test/test_shelve.py index ffd2120..ffcc98d 100644 --- a/Lib/test/test_shelve.py +++ b/Lib/test/test_shelve.py @@ -8,6 +8,21 @@ class TestCase(unittest.TestCase): fn = "shelftemp" + os.extsep + "db" + def test_close(self): + d1 = {} + s = shelve.Shelf(d1, protocol=2, writeback=False) + s['key1'] = [1,2,3,4] + self.assertEqual(s['key1'], [1,2,3,4]) + self.assertEqual(len(s), 1) + s.close() + self.assertRaises(ValueError, len, s) + try: + s['key1'] + except ValueError: + pass + else: + self.fail('Closed shelf should not find a key') + def test_ascii_file_shelf(self): try: s = shelve.open(self.fn, protocol=0) |