def setUp(self): self.game = Game()
class TestGame(unittest.TestCase): def setUp(self): self.game = Game() def test_creategame(self): self.assertIsInstance(self.game, Game) def test_rollAnAllGutterGame(self): self.game.roll_many(20, 0) self.assertEqual(self.game.score(), 0) def test_RollAllOnes(self): self.game.roll_many(20, 1) self.assertEqual(self.game.score(), 20) def test_RollASpare(self): # first two rolls make spare in first frame self.game.roll(5) self.game.roll(5) # third roll makes not a spare self.game.roll(3) self.game.roll_many(17,0) self.assertEqual(self.game.score(), 16) def test_RollAStrike(self): self.game.roll(10) self.game.roll(3) self.game.roll(3) self.game.roll_many(16,0) self.assertEqual(self.game.score(), 22) def test_CanRollAPerfectGame(self): self.game.roll_many(12, 10) self.assertEqual(self.game.score(), 300)