예제 #1
0
 def test_water_deadliness(self):
     error_msg = 'Water does not kill non-watersafe Insects'
     test_ant = ants.HarvesterAnt()
     test_water = ants.Water('water_TestProblemA4_0')
     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)
예제 #2
0
 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()
예제 #3
0
 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()
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 def test_water_inheritance_ant(self):
     error_msg = "Make sure to place the ant before killing it!"
     old_add_insect = ants.Place.add_insect
     def new_add_insect(self, insect):
         raise NotImplementedError()
     ants.Place.add_insect = new_add_insect
     test_ant = ants.HarvesterAnt()
     test_water = ants.Water('water_testProblemA4_0')
     failed = True
     try:
         test_water.add_insect(test_ant)
     except NotImplementedError:
         failed = False
     finally:
         ants.Place.add_insect = old_add_insect
     if failed:
         self.fail(msg=error_msg)
예제 #7
0
 def test_harvester(self):
     error_msg = 'HarvesterAnt did not add one food'
     old_food = self.colony.food
     ants.HarvesterAnt().action(self.colony)
     self.assertIs(old_food + 1, self.colony.food, error_msg)