예제 #1
0
파일: test.py 프로젝트: praba230890/hangman
    def test_numeric_input(self):
        """Test error message when user inputs numbers."""
        self.choice.return_value = "ant"
        self.input.side_effect = list("a2nt" "n")

        gallows.main()

        self.xprint.assert_any_call('Please enter a LETTER.')
예제 #2
0
파일: test.py 프로젝트: praba230890/hangman
    def test_multiple_char_input(self):
        """Test error message when user inputs multiple characters."""
        self.choice.return_value = "ant"
        self.input.side_effect = ["a", "nt", "n", "t", ] + ["n"]

        gallows.main()

        self.xprint.assert_any_call('Please enter a single letter.')
예제 #3
0
파일: test.py 프로젝트: movermeyer/hangman
    def test_numeric_input(self):
        """Test error message when user inputs numbers."""
        self.choice.return_value = "ant"
        self.input.side_effect = list("a2nt" "n")

        gallows.main()

        self.xprint.assert_any_call('Please enter a LETTER.')
예제 #4
0
파일: test.py 프로젝트: movermeyer/hangman
    def test_lose(self):
        """Test user lose scenario."""
        self.choice.return_value = "ant"
        self.input.side_effect = list("bcdefg" "n")

        gallows.main()

        self.xprint.assert_any_call('You have run out of guesses!')
예제 #5
0
파일: test.py 프로젝트: praba230890/hangman
    def test_lose(self):
        """Test user lose scenario."""
        self.choice.return_value = "ant" 
        self.input.side_effect = list("bcdefg" "n")

        gallows.main()

        self.xprint.assert_any_call('You have run out of guesses!')
예제 #6
0
파일: test.py 프로젝트: movermeyer/hangman
    def test_out_of_order(self):
        """Test win scenario with out of order input of letters."""
        self.choice.return_value = "ant"
        self.input.side_effect = list("tan" "n")

        gallows.main()

        self.xprint.assert_any_call('Yes! The secret word is "ant"! '
                                    'You have won!')
예제 #7
0
파일: test.py 프로젝트: movermeyer/hangman
    def test_win(self):
        """Test user win scenario."""
        self.choice.return_value = "ant"
        self.input.side_effect = list("ant" "n")

        gallows.main()

        self.xprint.assert_any_call('Yes! The secret word is "ant"! '
                                    'You have won!')
예제 #8
0
파일: test.py 프로젝트: movermeyer/hangman
    def test_same_letter_twice(self):
        """Test error message when user enters same letter twice."""
        self.choice.return_value = "ant"
        self.input.side_effect = list("anntn")

        gallows.main()

        self.xprint.assert_any_call("You have already guessed that letter. "
                                    "Choose again.")
예제 #9
0
파일: test.py 프로젝트: praba230890/hangman
    def test_same_letter_twice(self):
        """Test error message when user enters same letter twice."""
        self.choice.return_value = "ant"
        self.input.side_effect = list("anntn")

        gallows.main()

        self.xprint.assert_any_call("You have already guessed that letter. "
                                    "Choose again.")
예제 #10
0
파일: test.py 프로젝트: praba230890/hangman
    def test_out_of_order(self):
        """Test win scenario with out of order input of letters."""
        self.choice.return_value = "ant"
        self.input.side_effect = list("tan" "n")

        gallows.main()

        self.xprint.assert_any_call('Yes! The secret word is "ant"! '
                                    'You have won!')
예제 #11
0
파일: test.py 프로젝트: praba230890/hangman
    def test_win(self):
        """Test user win scenario."""
        self.choice.return_value = "ant"
        self.input.side_effect = list("ant" "n")

        gallows.main()

        self.xprint.assert_any_call('Yes! The secret word is "ant"! '
                                    'You have won!')
예제 #12
0
파일: test.py 프로젝트: praba230890/hangman
    def test_two_game(self):
        """Test two winning game plays."""
        self.choice.side_effect = ["ant", "baboon"]
        self.input.side_effect = list("ant" "y" "babon" "n")

        gallows.main()

        self.xprint.assert_any_call('Yes! The secret word is "ant"! '
                                    'You have won!')
        self.xprint.assert_any_call('Yes! The secret word is "baboon"! '
                                    'You have won!')
예제 #13
0
파일: test.py 프로젝트: Chennaipy/hangman
    def test_two_game(self):
        """Test two winning game plays."""
        from itertools import chain
        self.choice.side_effect = ["ant", "baboon"]
        self.input.side_effect = chain(list("ant"), ["yes"], list("babon"), ["no"])

        gallows.main()

        self.xprint.assert_any_call('Yes! The secret word is "ant"! '
                                    'You have won!')
        self.xprint.assert_any_call('Yes! The secret word is "baboon"! '
                                    'You have won!')
예제 #14
0
파일: test.py 프로젝트: movermeyer/hangman
    def test_two_game(self):
        """Test two winning game plays."""
        from itertools import chain
        self.choice.side_effect = ["ant", "baboon"]
        self.input.side_effect = chain(list("ant"), ["yes"], list("babon"),
                                       ["no"])

        gallows.main()

        self.xprint.assert_any_call('Yes! The secret word is "ant"! '
                                    'You have won!')
        self.xprint.assert_any_call('Yes! The secret word is "baboon"! '
                                    'You have won!')
예제 #15
0
파일: test.py 프로젝트: movermeyer/hangman
    def test_multiple_char_input(self):
        """Test error message when user inputs multiple characters."""
        self.choice.return_value = "ant"
        self.input.side_effect = [
            "a",
            "nt",
            "n",
            "t",
        ] + ["n"]

        gallows.main()

        self.xprint.assert_any_call('Please enter a single letter.')
예제 #16
0
def test_main_win(capsys):
    with mock.patch('builtins.input', side_effect=['%', 'B', 'L', 'A']):
        gallows.main(word)
        captured = capsys.readouterr()
        assert 'Congratulations! You win!' in captured.out
예제 #17
0
def test_main_lose(capsys):
    with mock.patch('builtins.input', side_effect=['e', 'r', 'r', 'o']):
        gallows.main(word)
        captured = capsys.readouterr()
        assert 'You lose!' in captured.out