Skip to content

Commit

Permalink
bug fix, thanks Durmus - http://disq.us/p/1ffu0qu
Browse files Browse the repository at this point in the history
  • Loading branch information
pybites committed Jan 22, 2017
1 parent 0ea6b57 commit 7578946
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions 02/game-help.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ def draw_letters():


def input_word(draw):
"""Ask player for a word.
Validations: 1) only use letters of draw, 2) valid dictionary word"""
"""Ask player for a word and validate against draw.
Use _validation(word, draw) helper."""
pass



def _validation(word, draw):
"""Validations: 1) only use letters of draw, 2) valid dictionary word"""
pass


Expand Down
10 changes: 10 additions & 0 deletions 02/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from game import draw_letters, calc_word_value, max_word_value
from game import get_possible_dict_words, _get_permutations_draw
from game import _validation

NUM_LETTERS = 7
TEST_WORDS = ('bob', 'julian', 'pybites', 'quit', 'barbeque')
Expand Down Expand Up @@ -38,5 +39,14 @@ def test_get_possible_dict_words(self):
words = get_possible_dict_words(self.fixed_draw)
self.assertEqual(len(words), 137)

def test_validation(self):
draw = list('garytev'.upper())
word = 'GARYTEV'
self.assertRaises(ValueError, _validation, word, draw)
word = 'F'
self.assertRaises(ValueError, _validation, word, draw)
word = 'GARETTA'
self.assertRaises(ValueError, _validation, word, draw)

if __name__ == "__main__":
unittest.main()

0 comments on commit 7578946

Please sign in to comment.