Beispiel #1
0
 def test_str_strike(self):
     """
     Checks if the string representation of the frame is correct for a strike
     """
     frame = BowlingFrame("test")
     frame.registerThrowing(10)
     self.assertEqual(frame.__str__(), '| | |X|')
     self.assertEqual(frame.__str__(True), '|     |')
Beispiel #2
0
 def test_str_hole_ending(self):
     """
     Checks if the string representation of the frame is correct for a hole
     """
     frame = BowlingFrame("test", ending=True)
     frame.registerThrowing(3)
     frame.registerThrowing(4)
     self.assertEqual(frame.__str__(), '| |3|4| |')
     self.assertEqual(frame.__str__(True), '| 7     |')
Beispiel #3
0
 def test_str_spare_ending2(self):
     """
     Checks if the string representation of the ending frame is correct for a spare
     """
     frame = BowlingFrame("test", ending=True)
     frame.registerThrowing(10)
     frame.registerThrowing(5)
     frame.registerThrowing(5)
     self.assertEqual(frame.__str__(), '| |X|5|/|')
     self.assertEqual(frame.__str__(True), '| 20    |')
Beispiel #4
0
 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())