def setup(self): self.race = Race() self.race.add(Reindeer("Comet", 14, 10, 127)) self.race.add(Reindeer("Dancer", 16, 11, 162))
class TestRace(object): def setup(self): self.race = Race() self.race.add(Reindeer("Comet", 14, 10, 127)) self.race.add(Reindeer("Dancer", 16, 11, 162)) def test_t_1(self): self.race.step() assert self.race.reindeer["Comet"].position == 14 assert self.race.reindeer["Comet"].state == "flying" assert self.race.reindeer["Comet"].points == 0 assert self.race.reindeer["Dancer"].position == 16 assert self.race.reindeer["Dancer"].state == "flying" assert self.race.reindeer["Dancer"].points == 1 def test_t_10(self): self.race.step(10) assert self.race.reindeer["Comet"].position == 140 assert self.race.reindeer["Comet"].state == "resting" assert self.race.reindeer["Dancer"].position == 160 assert self.race.reindeer["Dancer"].state == "flying" def test_t_11(self): self.race.step(11) assert self.race.reindeer["Comet"].position == 140 assert self.race.reindeer["Comet"].state == "resting" assert self.race.reindeer["Dancer"].position == 176 assert self.race.reindeer["Dancer"].state == "resting" def test_t_138(self): self.race.step(138) assert self.race.reindeer["Comet"].position == 154 assert self.race.reindeer["Comet"].state == "flying" assert self.race.reindeer["Dancer"].position == 176 assert self.race.reindeer["Dancer"].state == "resting" def test_t_140(self): self.race.step(140) assert self.race.reindeer["Comet"].points == 1 assert self.race.reindeer["Dancer"].points == 139 def test_t_174(self): self.race.step(174) assert self.race.reindeer["Comet"].position == 280 assert self.race.reindeer["Comet"].state == "resting" assert self.race.reindeer["Dancer"].position == 192 assert self.race.reindeer["Dancer"].state == "flying" def test_t_1000(self): self.race.step(1000) assert self.race.reindeer["Comet"].position == 1120 assert self.race.reindeer["Comet"].state == "resting" assert self.race.reindeer["Comet"].points == 312 assert self.race.reindeer["Dancer"].position == 1056 assert self.race.reindeer["Dancer"].state == "resting" assert self.race.reindeer["Dancer"].points == 689 def test_max_position(self): self.race.step(1) assert self.race.max_position() == 16 self.race.step(999) assert self.race.max_position() == 1120 def test_max_points(self): self.race.step(1) assert self.race.max_points() == 1 self.race.step(999) assert self.race.max_points() == 689