Beispiel #1
0
    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")
Beispiel #2
0
    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")