MCPcopy Index your code
hub / github.com/python/cpython / test_check_closed

Method test_check_closed

Lib/test/test_dbm_dumb.py:205–225  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

203 db.keys()
204
205 def test_check_closed(self):
206 f = dumbdbm.open(_fname, 'c')
207 f.close()
208
209 for meth in (partial(operator.delitem, f),
210 partial(operator.setitem, f, 'b'),
211 partial(operator.getitem, f),
212 partial(operator.contains, f)):
213 with self.assertRaises(dumbdbm.error) as cm:
214 meth('test')
215 self.assertEqual(str(cm.exception),
216 "DBM object has already been closed")
217
218 for meth in (operator.methodcaller('keys'),
219 operator.methodcaller('iterkeys'),
220 operator.methodcaller('items'),
221 len):
222 with self.assertRaises(dumbdbm.error) as cm:
223 meth(f)
224 self.assertEqual(str(cm.exception),
225 "DBM object has already been closed")
226
227 def test_create_new(self):
228 with dumbdbm.open(_fname, 'n') as f:

Callers

nothing calls this directly

Calls 7

partialClass · 0.90
methFunction · 0.85
strFunction · 0.85
openMethod · 0.45
closeMethod · 0.45
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected