示例#1
0
 def test_seven_wrong_guesses_should_end_game(self):
     """Test method."""
     game = GuessingGame("secret")
     game.guess('a')
     game.guess('b')
     game.guess('d')
     game.guess('f')
     game.guess('g')
     game.guess('h')
     game.guess('i')
     assert not game.in_progress
示例#2
0
 def test_seven_wrong_guesses_should_lose(self):
     """Test method."""
     game = GuessingGame("secret")
     game.guess('a')
     game.guess('b')
     game.guess('d')
     game.guess('f')
     game.guess('g')
     game.guess('h')
     game.guess('i')
     assert game.lost
示例#3
0
 def test_guessing_same_character_should_not_count(self):
     """Test method."""
     game = GuessingGame("secret")
     game.guess('s')
     assert len(game.guesses) == 1
     game.guess('s')
     assert len(game.guesses) == 1
     game.guess('a')
     assert game.wrong_guesses == 1
     game.guess('a')
     assert game.wrong_guesses == 1
示例#4
0
 def test_correct_guesses_should_win(self):
     """Test method."""
     game = GuessingGame("secret")
     game.guess('s')
     game.guess('e')
     game.guess('c')
     game.guess('r')
     # game.guess('e')
     game.guess('t')
     assert game.won
示例#5
0
 def test_correct_guesses_should_end_game(self):
     """Test method."""
     game = GuessingGame("secret")
     game.guess('s')
     game.guess('e')
     game.guess('c')
     game.guess('r')
     # game.guess('e')
     game.guess('t')
     assert not game.in_progress
示例#6
0
 def test_wrong_guesses_should_increment_wrong_guesses(self):
     """Test method."""
     game = GuessingGame("secret")
     game.guess('a')
     assert game.wrong_guesses == 1
     game.guess('b')
     assert game.wrong_guesses == 2
     game.guess('d')
     assert game.wrong_guesses == 3
     game.guess('f')
     assert game.wrong_guesses == 4
     game.guess('g')
     assert game.wrong_guesses == 5
     game.guess('h')
     assert game.wrong_guesses == 6
示例#7
0
 def test_guesses_should_be_added_to_previous_guesses(self, guess):
     """Test method."""
     game = GuessingGame("secret")
     game.guess(guess)
     assert guess in game.guesses
示例#8
0
 def test_guesses_should_be_case_insensitive(self):
     """Test method."""
     game = GuessingGame("secret")
     assert game.guess('s') == GuessResult.CORRECT
     assert game.guess('E') == GuessResult.CORRECT
示例#9
0
 def test_multiple_guess_should_return_multiple(self, guess):
     """Test method."""
     game = GuessingGame("secret")
     game.guess(guess)
     assert game.guess(guess) == GuessResult.MULTIPLE
示例#10
0
 def test_incorrect_guess_should_return_incorrect(self, guess):
     """Test method."""
     game = GuessingGame("secret")
     assert game.guess(guess) == GuessResult.INCORRECT
示例#11
0
 def test_guess_should_be_a_letter(self, guess):
     """Test method."""
     game = GuessingGame("secret")
     assert game.guess(guess) == GuessResult.NOTLEGAL