def console_parser(): parser = argparse.ArgumentParser( description= 'Утилита для расчета результата партии на основе результата бросков', add_help=True) parser.add_argument('-result', '--result', type=str, help='Результаты бросков') args = parser.parse_args() if args.result: game = bowling.Game(game_result=args.result, need_log=True) print(game.calculate_result()) else: print('Укажите параметры или воспользуйтесь --help')
def test_gutter_game(self): pinHits = [[0, 0]] * 10 self.assertEqual(0, bowling.Game().calc_score(pinHits))
def test_strike4(self): pinHits = [[0, 0]] * 9 + [[10, 0], [2, 1]] self.assertEqual(13, bowling.Game().calc_score(pinHits))
def test_first(self): pinHits = [[2, 6]] + [[0, 0]] * 9 self.assertEqual(8, bowling.Game().calc_score(pinHits))
def test_score_of_next_2_balls2(self): pinHits = [[0, 0], [5, 3]] current_frame = 0 self.assertEqual(8, bowling.Game().get_bonus(current_frame, pinHits))
def test_spares4(self): pinHits = [[0, 0]] * 9 + [[9, 1], [2, 0]] self.assertEqual(12, bowling.Game().calc_score(pinHits))
def test_strikes1(self): pinHits = [[10, 0], [10, 0], [10, 0]] + [[0, 0]] * 7 self.assertEqual(60, bowling.Game().calc_score(pinHits))
def testRooteGameFunction_PerfectGame(self): self.assertEqual(bowling.Game('XXXXXXXXXXXX').score, 300)
def test_spares2(self): pinHits = [[5, 5], [5, 0], [3, 7], [1, 0]] self.assertEqual(32, bowling.Game().calc_score(pinHits))
def test_spares(self): pinHits = [[5, 5], [5, 0]] self.assertEqual(20, bowling.Game().calc_score(pinHits))
def test_3(self): pinHits = [[2, 0], [5, 0]] self.assertEqual(7, bowling.Game().calc_score(pinHits))
def setUp(self): self.game = bowling.Game()
def game(): return bowling.Game()
def testFinishedGame(self, inputString, expectedScore): self.assertEqual(bowling.calculate_finished_game(inputString), expectedScore) self.assertEqual(bowling.Game(inputString).score, expectedScore)
def test_perfect_game(self): pinHits = [[10, 0]] * 12 self.assertEqual(300, bowling.Game().calc_score(pinHits))
def test_spares3(self): pinHits = [[10, 0], [5, 1]] + [[0, 0]] * 8 self.assertEqual(22, bowling.Game().calc_score(pinHits))
def test_2(self): pinHits = [[0, 0]] self.assertEqual(0, bowling.Game().calc_score(pinHits))
def testUnfinishedGameWithRawInputs(self, inputString, expectedScore): originalRawInput = __builtins__.raw_input __builtins__.raw_input = lambda _: inputString self.assertEqual(bowling.Game().score, expectedScore) __builtins__.raw_input = originalRawInput