def setUp(self): AntTest.setUp(self) self.place = ants.Place('TestProblem8') self.bodyguard = ants.BodyguardAnt() self.bodyguard2 = ants.BodyguardAnt() self.test_ant = ants.Ant() self.test_ant2 = ants.Ant() self.harvester = ants.HarvesterAnt()
def setUp(self): AntTest.setUp(self) self.place = ants.Place('TestProblem8') self.bush = ants.BushAnt() self.bush2 = ants.BushAnt() self.test_ant = ants.Ant() self.test_ant2 = ants.Ant() self.harvester = ants.HarvesterAnt()
def test_remove_bodyguard(self): error_msg = 'Removing BodyguardAnt also removes containing ant' place = self.colony.places['tunnel_0_0'] bodyguard = ants.BodyguardAnt() test_ant = ants.Ant(1) place.add_insect(bodyguard) place.add_insect(test_ant) self.colony.remove_ant('tunnel_0_0') self.assertIs(place.ant, test_ant, error_msg)
def test_water_deadliness_2(self): error_msg = 'Water does not kill non-watersafe Insects' test_ants = [ants.Bee(1000000), ants.HarvesterAnt(), ants.Ant(), ants.ThrowerAnt()] test_ants[0].watersafe = False #Make the bee non-watersafe test_water = ants.Water('water_TestProblemA4_0') for test_ant in test_ants: test_water.add_insect(test_ant) self.assertIsNot(test_ant, test_water.ant, msg=error_msg) self.assertIs(0, test_ant.armor, msg=error_msg)
def test_water_deadliness_with_big_soggy_bee(self): error_msg = "Water does not hurt all non-watersafe Insects" test_ants = [ ants.Bee(1000000), ants.HarvesterAnt(), ants.Ant(), ants.ThrowerAnt() ] test_ants[0].watersafe = False # Make the Bee non-watersafe test_water = ants.Water("water_TestProblemA4_0") for test_ant in test_ants: test_water.add_insect(test_ant) self.assertIsNot(test_ant, test_water.ant, msg=error_msg) self.assertIs(0, test_ant.armor, msg=error_msg)
def test_remove_bodyguard(self): """This tests the following statement: "If a BodyguardAnt containing another ant is removed, then the ant it is containing should be placed where the BodyguardAnt used to be." Since this is optional, you can get a full score even if your program fails this doctest.""" error_msg = 'Removing BodyguardAnt also removes containing ant' place = self.colony.places['tunnel_0_0'] bodyguard = ants.BodyguardAnt() test_ant = ants.Ant(1) place.add_insect(bodyguard) place.add_insect(test_ant) self.colony.remove_ant('tunnel_0_0') self.assertIs(place.ant, test_ant, error_msg)