def test_delete_withNoneTypeArgumentKey_shouldRaiseValueError(self): bst = Treap() with self.assertRaises(ValueError): bst.delete(None) with self.assertRaises(ValueError): del bst[None]
def test_delete_withKeyNotInTree_shouldNotModifyTree(self): bst = Treap() for i in range(1, 20): bst.put(i, str(i)) for i in range(20, 30): bst.delete(i) self.assertEqual(19, len(bst)) for j in range(1, 20): self.assertIn(j, bst)
def test_delete_withKeyInTree_shouldDeleteKeyFromTree(self): bst = Treap() for i in range(1, 20): bst.put(i, str(i)) for i in range(1, 20): bst.delete(i) self.assertEqual(19 - i, len(bst)) self.assertNotIn(i, bst) for j in range(i + 1, 20): self.assertIn(j, bst)