def test_animal(self): world = World.World() animal = World.Animal() animal.step() animal.draw() animal.undraw() animal.redraw() animal.die()
def test_delay(self): world = World.World() animal = World.Animal() world.delay = 0.3 self.assertEqual(animal.delay, 0.3) self.assertEqual(world.delay, 0.3) animal.delay = 0.4 self.assertEqual(animal.delay, 0.4) self.assertEqual(world.delay, 0.4)
def test_step(self): world = World.World() a1 = World.Animal() a1.x = 100 a2 = World.Animal() a2.x = 200 self.assertEqual(len(world.animals), 2) def get_x(animal): return animal.x res = world.map_animals(get_x) self.assertEqual(len(res), 2) self.assertEqual(res[1], 200) world.step() world.canvas = world.ca() world.clear()