예제 #1
0
파일: tests.py 프로젝트: realsuayip/quizz
    def test_question_pre(self):
        question = Question("What?")
        Quiz(questions=[question])

        self.assertEqual(
            "* Question 1/1. [No answer]\n", question.get_question_pre()
        )

        question.answer = "Good answer"
        self.assertEqual(
            "* Question 1/1. [Good answer]\n", question.get_question_pre()
        )

        question.answer = Option(value="A", expression="Best answer.")
        self.assertEqual(
            "* Question 1/1. [A) Best answer.]\n", question.get_question_pre()
        )
예제 #2
0
파일: tests.py 프로젝트: realsuayip/quizz
    def test_skip(self, mock_stdout, *_):
        question = Question("Hello?", commands=[Skip], required=False)
        question.answer = "World"
        question.ask()

        mock_stdout.assert_called_with("You decided to skip this question.")

        self.assertIsNone(question.answer)
        self.assertEqual(1, question.attempt)
예제 #3
0
파일: tests.py 프로젝트: realsuayip/quizz
    def test_answer_persists_on_empty_input(self, *_):
        question = Question("What?", required=False)
        question.answer = "Previous Answer"
        question.ask()

        self.assertEqual("Previous Answer", question.answer)