def test_delete(self): ht = HashTable() ht.set('I', 1) ht.set('V', 5) ht.set('X', 10) assert ht.length() == 3 ht.delete('I') ht.delete('X') assert ht.length() == 1 with self.assertRaises(KeyError): ht.delete('X') # Key no longer exists with self.assertRaises(KeyError): ht.delete('A') # Key does not exist
hashTable.insert_in_avl_tree(table, 45, record15) hashTable.insert_in_avl_tree(table, 505, record16) hashTable.insert_in_avl_tree(table, 90, record17) hashTable.insert_in_avl_tree(table, 9, record18) hashTable.insert_in_avl_tree(table, 76, record19) print '---------------' for item in table: print '-----' if isinstance(item, avltree): print item.inorder_traverse() else: print item print '---------------' hashTable.delete(table, 49) print '***' hashTable.delete(table, 52) print '***' hashTable.delete(table, 201) print '***' record99 = DirectoryItem('TestUser99', 'LastNameTest99', 'street', 33990009, 338700089) print '***' hashTable.modify_record(table, 505, record99) print '***' hashTable.search(table, 201) print '***' hashTable.search(table, 31) print '---------------'