def test_input_invlaid_space(self, mock_input):
     play = play_again()
     self.assertEqual(sys.stdout.getvalue().strip(), "Please enter 'Y' or 'N'.")
     self.assertEqual(play, True)
 def test_input_y(self, mock_input):
     play = play_again()
     self.assertEqual(play, True)
 def test_input_n(self, mock_input):
     play = play_again()
     self.assertEqual(play, False)
     self.assertEqual(sys.stdout.getvalue().strip(), "Thanks for playing!!")
示例#4
0
            # Player inputs the answer number
            choice = input_answer()

            # Compare choice to correct answer, give response and apply points
            points = add_points(points, choice, correct_answer)
        break
    return points


# Main - This loop does the program setup and runs the start function
if __name__ == "__main__":
    playing = True
    while playing:
        # Setup counters
        ques_count = 0
        points = 0

        # Print the greeting
        opening_info()

        # Setup the numbers & questions variables
        questions = get_text_from_csv_file()
        num_list = question_number_list(questions)

        # Main loop prints questions, answers and score
        points = start(points, ques_count, questions)

        # Prints points and play again
        print_score(points)
        playing = play_again()