def test_run_simple(self): final_population = None other_data = "hi" r = run.Run(self.init_pop, final_population, {}, self.temp_file, other_data) with persistence.get_shelf(self.temp_file) as shelf: r_saved = shelf.values()[0] self.assertEquals(r_saved.final_population, None) self.assertEquals(r_saved.other_data, "hi")
def test_save_with_unique_key(self): for _ in range(10): persistence.save_with_unique_key(self.temp_file, None) with persistence.get_shelf(self.temp_file) as shelf: self.assertEqual(len(shelf), 10)
def test_get_shelf(self): persistence.save(self.temp_file, "a", 1) persistence.save(self.temp_file, "b", 2) persistence.save(self.temp_file, "c", 3) with persistence.get_shelf(self.temp_file) as shelf: self.assertEqual(len(shelf), 3)