def test_question_prompt_changes_with_quiz(self): question = Question("What?") question2 = Question("Hello?") Quiz(questions=[question, question2]) self.assertEqual( "* Question 1/2. [No answer]\nWhat?", question.get_prompt() ) question.update_scheme(Scheme(suffix="Suf", prefix="Pre")) self.assertEqual( "* Question 1/2. [No answer]\nPreWhat?Suf", question.get_prompt() )
def test_suffix(self, mock_stdin): question = Question("What?") question_with_suffix = Question("What?", suffix="test") self.assertEqual("", question.get_suffix()) self.assertEqual("test", question_with_suffix.get_suffix()) self.assertEqual("What?", question.get_prompt()) self.assertEqual("What?test", question_with_suffix.get_prompt()) question.ask() mock_stdin.assert_called_with("What?") question_with_suffix.ask() mock_stdin.assert_called_with("What?test")
def test_prefix(self, mock_stdin): question_with_prefix = Question("What?", prefix="test2") self.assertEqual("test2", question_with_prefix.get_prefix()) self.assertEqual("test2What?", question_with_prefix.get_prompt()) question_with_prefix.ask() mock_stdin.assert_called_with("test2What?")
def test_prefix_suffix(self, mock_stdin): question_with_prefix_suffix = Question( "What?", prefix="Pre", suffix="Suf" ) self.assertEqual("Pre", question_with_prefix_suffix.get_prefix()) self.assertEqual("Suf", question_with_prefix_suffix.get_suffix()) self.assertEqual( "PreWhat?Suf", question_with_prefix_suffix.get_prompt() ) question_with_prefix_suffix.ask() mock_stdin.assert_called_with("PreWhat?Suf")