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

Method _test_remove_or_delitem

Lib/test/test_mailbox.py:202–222  ·  view source on GitHub ↗
(self, method)

Source from the content-addressed store, hash-verified

200 self._test_remove_or_delitem(self._box.__delitem__)
201
202 def _test_remove_or_delitem(self, method):
203 # (Used by test_remove() and test_delitem().)
204 key0 = self._box.add(self._template % 0)
205 key1 = self._box.add(self._template % 1)
206 self.assertEqual(len(self._box), 2)
207 method(key0)
208 self.assertEqual(len(self._box), 1)
209 self.assertRaises(KeyError, lambda: self._box[key0])
210 self.assertRaises(KeyError, lambda: method(key0))
211 self.assertEqual(self._box.get_string(key1), self._template % 1)
212 key2 = self._box.add(self._template % 2)
213 self.assertEqual(len(self._box), 2)
214 method(key2)
215 self.assertEqual(len(self._box), 1)
216 self.assertRaises(KeyError, lambda: self._box[key2])
217 self.assertRaises(KeyError, lambda: method(key2))
218 self.assertEqual(self._box.get_string(key1), self._template % 1)
219 method(key1)
220 self.assertEqual(len(self._box), 0)
221 self.assertRaises(KeyError, lambda: self._box[key1])
222 self.assertRaises(KeyError, lambda: method(key1))
223
224 def test_discard(self, repetitions=10):
225 # Discard messages

Callers 2

test_removeMethod · 0.95
test_delitemMethod · 0.95

Calls 5

methodFunction · 0.85
addMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
get_stringMethod · 0.45

Tested by

no test coverage detected