Exemple #1
0
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')
Exemple #2
0
 def test_gutter_game(self):
     pinHits = [[0, 0]] * 10
     self.assertEqual(0, bowling.Game().calc_score(pinHits))
Exemple #3
0
 def test_strike4(self):
     pinHits = [[0, 0]] * 9 + [[10, 0], [2, 1]]
     self.assertEqual(13, bowling.Game().calc_score(pinHits))
Exemple #4
0
 def test_first(self):
     pinHits = [[2, 6]] + [[0, 0]] * 9
     self.assertEqual(8, bowling.Game().calc_score(pinHits))
Exemple #5
0
 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))
Exemple #6
0
 def test_spares4(self):
     pinHits = [[0, 0]] * 9 + [[9, 1], [2, 0]]
     self.assertEqual(12, bowling.Game().calc_score(pinHits))
Exemple #7
0
 def test_strikes1(self):
     pinHits = [[10, 0], [10, 0], [10, 0]] + [[0, 0]] * 7
     self.assertEqual(60, bowling.Game().calc_score(pinHits))
Exemple #8
0
 def testRooteGameFunction_PerfectGame(self):
     self.assertEqual(bowling.Game('XXXXXXXXXXXX').score, 300)
Exemple #9
0
 def test_spares2(self):
     pinHits = [[5, 5], [5, 0], [3, 7], [1, 0]]
     self.assertEqual(32, bowling.Game().calc_score(pinHits))
Exemple #10
0
 def test_spares(self):
     pinHits = [[5, 5], [5, 0]]
     self.assertEqual(20, bowling.Game().calc_score(pinHits))
Exemple #11
0
 def test_3(self):
     pinHits = [[2, 0], [5, 0]]
     self.assertEqual(7, bowling.Game().calc_score(pinHits))
 def setUp(self):
     self.game = bowling.Game()
Exemple #13
0
def game():
    return bowling.Game()
Exemple #14
0
def testFinishedGame(self, inputString, expectedScore):
    self.assertEqual(bowling.calculate_finished_game(inputString),
                     expectedScore)
    self.assertEqual(bowling.Game(inputString).score, expectedScore)
Exemple #15
0
 def test_perfect_game(self):
     pinHits = [[10, 0]] * 12
     self.assertEqual(300, bowling.Game().calc_score(pinHits))
Exemple #16
0
 def test_spares3(self):
     pinHits = [[10, 0], [5, 1]] + [[0, 0]] * 8
     self.assertEqual(22, bowling.Game().calc_score(pinHits))
Exemple #17
0
 def test_2(self):
     pinHits = [[0, 0]]
     self.assertEqual(0, bowling.Game().calc_score(pinHits))
Exemple #18
0
def testUnfinishedGameWithRawInputs(self, inputString, expectedScore):
    originalRawInput = __builtins__.raw_input
    __builtins__.raw_input = lambda _: inputString
    self.assertEqual(bowling.Game().score, expectedScore)
    __builtins__.raw_input = originalRawInput