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

Method test_context_manager

Lib/test/test_dbm_ndbm.py:62–72  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

60 self.fail()
61
62 def test_context_manager(self):
63 with dbm.ndbm.open(self.filename, 'c') as db:
64 db["ndbm context manager"] = "context manager"
65
66 with dbm.ndbm.open(self.filename, 'r') as db:
67 self.assertEqual(list(db.keys()), [b"ndbm context manager"])
68
69 with self.assertRaises(dbm.ndbm.error) as cm:
70 db.keys()
71 self.assertEqual(str(cm.exception),
72 "DBM object has already been closed")
73
74 def test_bytes(self):
75 with dbm.ndbm.open(self.filename, 'c') as db:

Callers

nothing calls this directly

Calls 6

listClass · 0.85
strFunction · 0.85
openMethod · 0.45
assertEqualMethod · 0.45
keysMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected