def test_play(self): """ Tests if the play build up correctly """ game = BowlingGame(['test']) game.play([2, 3, 6, 4, 8, 1, 10, 3, 0, 10, 10, 10, 10, 1, 9, 5], verbose=False) self.assertEqual(len(game.frames['test']), 10) self.assertEqual(BowlingGame.computeScoreOnFrames(game.frames['test']), 164)
def test_str(self): """ Tests if the string representation of the game is correct """ frame1 = BowlingFrame("test") frame2 = BowlingFrame("test") game = BowlingGame(['test']) game.frames = {"test": [frame1, frame2]} representation = 'test\n' + frame1.__str__() + ' ' + frame2.__str__() + ' \n' + \ frame1.__str__(True) + ' ' + frame2.__str__(True) + ' \n' self.assertEqual(str(game).strip(), representation.strip())
def setUp(self): self.game = BowlingGame()
import sys from bowling.game import BowlingGame if __name__ == '__main__': players = ["Player1"] if len(sys.argv) > 1: players = sys.argv[1:] game = BowlingGame(players) game.play()
def game(): yield BowlingGame()