summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-04-26 20:57:11 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-04-26 20:57:11 (GMT)
commit4453cf576a18bc98131b7117691a8ea311b348cd (patch)
treecad2a020e1f5c7c6f7a0877a00da878e57df7235 /Lib/test
parent5e746f237354f9fe345743616c40b96229910590 (diff)
parente3083d3ad541432e2420869c7ed56fb9aff7a453 (diff)
downloadcpython-4453cf576a18bc98131b7117691a8ea311b348cd.zip
cpython-4453cf576a18bc98131b7117691a8ea311b348cd.tar.gz
cpython-4453cf576a18bc98131b7117691a8ea311b348cd.tar.bz2
merge 3.4 (#19385)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_dbm_dumb.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py
index 7601e64..29f48a3 100644
--- a/Lib/test/test_dbm_dumb.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -3,10 +3,12 @@
"""
import io
+import operator
import os
import unittest
import dbm.dumb as dumbdbm
from test import support
+from functools import partial
_fname = support.TESTFN
@@ -190,12 +192,31 @@ class DumbDBMTestCase(unittest.TestCase):
with dumbdbm.open(_fname, 'r') as db:
self.assertEqual(list(db.keys()), [b"dumbdbm context manager"])
- # This currently just raises AttributeError rather than a specific
- # exception like the GNU or NDBM based implementations. See
- # http://bugs.python.org/issue19385 for details.
- with self.assertRaises(Exception):
+ with self.assertRaises(dumbdbm.error):
db.keys()
+ 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")
+
+ 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")
+
def tearDown(self):
_delete_files()