Пример #1
0
    def test_check_word(self, fake):
        fake.return_value = 'Weapon'
        hangman = Hangman()
        hangman.generate_word()
        hangman.check_word('Bear')

        assert not hangman.is_finalized()

        hangman.check_word('  WeaPOn  ')
        assert hangman.is_finalized()
Пример #2
0
def hangman_show():
    while True:
        hangman = Hangman()
        user_win = hangman_round(5, hangman)
        if user_win:
            print('Congratulations you won')
        else:
            print(f'You lose, correct word is {hangman.current_word}')
        print('Try again? [y,n]: ')
        if(input() != 'y'):
            break
Пример #3
0
    def test_check_letter(self, fake):
        fake.return_value = 'Nature'
        hangman = Hangman()
        hangman.generate_word()

        assert not hangman.check_letter('H')
        assert not hangman.check_letter('Z')
        assert hangman.check_letter('a')
        assert hangman.check_letter('A')
        assert hangman.check_letter('E')
Пример #4
0
    def test_show_status(self):
        hangman = Hangman("word")
        self.assertTrue(hangman.show_status() == "____")

        hangman.take_guess("w")

        self.assertTrue(hangman.show_status() == "w___")
Пример #5
0
    def test_is_finalized(self, fake):
        fake.return_value = 'Hello'
        hangman = Hangman()
        hangman.generate_word()
        hangman.check_letter('H')
        hangman.check_letter('E')
        hangman.check_letter('L')
        hangman.check_letter('o')

        # test if is finalized
        assert hangman.is_finalized()

        fake.return_value = 'Bye'
        hangman.generate_word()
        hangman.check_letter('a')
        hangman.check_letter('b')
        hangman.check_letter('c')

        # test if is not finalized
        assert not hangman.is_finalized()
Пример #6
0
    def test_is_game_running(self):
        hangman = Hangman("word")
        self.assertTrue(hangman.is_game_running())

        hangman = Hangman("")
        self.assertFalse(hangman.is_game_running())
Пример #7
0
 def test_start_new_game(self):
     hangman = Hangman("word")
     self.assertTrue(type(hangman) is Hangman)
Пример #8
0
 def test_user_has_won(self):
     hangman = Hangman("word")
     self.assertFalse(hangman.user_has_won())
Пример #9
0
 def test_take_guess(self):
     hangman = Hangman("word")
     self.assertTrue(hangman.take_guess("w"))
     self.assertFalse(hangman.take_guess("t"))