Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11)

Unified Diff: Lib/test/test_dbm_dumb.py

Issue 19385: dbm.dumb should be consistent when the database is closed
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/dbm/dumb.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_dbm_dumb.py Wed Oct 23 22:03:45 2013 +0200
+++ b/Lib/test/test_dbm_dumb.py Thu Oct 31 23:21:09 2013 +0200
@@ -8,6 +8,8 @@
import unittest
import dbm.dumb as dumbdbm
from test import support
+import operator
+from functools import partial
_fname = support.TESTFN
@@ -186,6 +188,28 @@
self.assertEqual(expected, got)
f.close()
+ def test_check_closed(self):
+ f = dumbdbm.open(_fname, 'c')
+ f.close()
+
+ for meth in (partial(operator.delitem, f),
+ partial(operator.setitem, f, 'b'),
+ partial(operator.getitem, f),
+ partial(operator.contains, f)):
+ with self.assertRaises(dumbdbm.error) as cm:
+ meth('test')
+ self.assertEqual(str(cm.exception),
+ "DBM object has already been closed")
vajrasky 2013/11/01 16:22:32 It needs one more space. " in "DBM should be under
+
+ for meth in (operator.methodcaller('keys'),
+ operator.methodcaller('iterkeys'),
+ operator.methodcaller('items'),
+ len):
+ with self.assertRaises(dumbdbm.error) as cm:
+ meth(f)
+ self.assertEqual(str(cm.exception),
+ "DBM object has already been closed")
vajrasky 2013/11/01 16:22:32 It needs one more space. " in "DBM should be under
+
def tearDown(self):
_delete_files()
« no previous file with comments | « Lib/dbm/dumb.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+