MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_with

Method test_with

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

assertEqualMethod · 0.95
assertRaisesMethod · 0.95
failMethod · 0.95
lenFunction · 0.85

Tested by

no test coverage detected