class ComputerStrategyTest(unittest.TestCase): def setUp(self): self.computer = Computer() def test_will_play(self): """These tests explain the logic of when the computer will hold""" self.computer.score = {"Maurice": 100, "Computer": 200} # the computer is ahead self.assertFalse(self.computer.will_play(3), "The computer holds if ahead.") self.assertTrue(self.computer.will_play(4), "The computer plays if there are more than 3 dice") self.computer.turn_scorer.score_between_rolls = 401 self.assertFalse(self.computer.will_play(2), "The computer holds if it scored more than 400 and has 2 dice left") self.assertFalse(self.computer.will_play(1), "The computer always holds if it only has 1 dice left") self.computer.score = {"Maurice": 300, "Computer": 200} # the computer is behind self.computer.turn_scorer.score_between_rolls = 0 self.assertTrue(self.computer.will_play(4), "The computer plays if more than 3 dice") self.assertTrue(self.computer.will_play(3), "The computer plays if behind") self.assertTrue(self.computer.will_play(2), "The computer plays if 2 dice and less than 400 score") self.computer.turn_scorer.score_between_rolls = 401 self.assertFalse(self.computer.will_play(2), "The computer holds if 2 dice and more than 400 score") self.assertFalse(self.computer.will_play(1), "The computer holds if only 1 dice.")
def setUp(self): self.computer = Computer()