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

Method test_with

Lib/test/test_shelve.py:151–163  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

149 self.assertNotEqual(p1, p2) # Write creates new object in store
150
151 def test_with(self):
152 d1 = {}
153 with shelve.Shelf(d1, protocol=2, writeback=False) as s:
154 s['key1'] = [1,2,3,4]
155 self.assertEqual(s['key1'], [1,2,3,4])
156 self.assertEqual(len(s), 1)
157 self.assertRaises(ValueError, len, s)
158 try:
159 s['key1']
160 except ValueError:
161 pass
162 else:
163 self.fail('Closed shelf should not find a key')
164
165 def test_default_protocol(self):
166 with shelve.Shelf({}) as s:

Callers

nothing calls this directly

Calls 3

assertEqualMethod · 0.95
assertRaisesMethod · 0.95
failMethod · 0.95

Tested by

no test coverage detected