From f04358d765eeb1a6f829e928b8dc3e1aeabd3c09 Mon Sep 17 00:00:00 2001 From: grizax Date: Tue, 20 Jan 2015 08:19:07 -0500 Subject: [PATCH 1/2] Mystery Word Assignment --- README.md | 143 +++----------------------- mystery_word.py | 232 ++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 6 +- tests/mystery_word.py | 232 ++++++++++++++++++++++++++++++++++++++++++ tests/test_mystery.py | 29 ++++++ 5 files changed, 511 insertions(+), 131 deletions(-) create mode 100644 mystery_word.py create mode 100644 tests/mystery_word.py create mode 100644 tests/test_mystery.py diff --git a/README.md b/README.md index d961ec3..f9aa298 100644 --- a/README.md +++ b/README.md @@ -1,135 +1,18 @@ -# Mystery Word +Introduction +This app works and passes pep8 specs. The test file is incomplete because I don’t quite understand testing at this point. -## Description +Documentation +This is a Mystery Word game. The user has 8 guesses to guess a word given at random. -Implement the game of Mystery Word. +Setup + 1. Git or download this folder + 2. Run this program in Terminal: python mystery_word.py + 3. Run test using: py.test test_mystery.py + 4. Enjoy -## Objectives +Requirements +Have Python 3 installed on your computer -### Learning Objectives +Acknowledgements +The included ASCII art was found at http://www.asciiworld.com for endgame graphics -After completing this assignment, you should understand: - -* All the basics of Python! - -### Performance Objectives - -After completing this assignment, you should be able to: - -* Create an interactive program. -* Read from a file. -* Choose a random value. -* Keep track of state. -* Test your code. - -## Details - -### Deliverables - -* A Git repo called mystery-word containing at least: - * a `README.md` file explaining how to run your project - * a `requirements.txt` file with any third-party packages needed - * a suite of tests for your project - -### Requirements - -* Passing unit tests -* No PEP8 warnings or errors - -## Normal Mode - -You will implement the game Mystery Word. In your game, you will be playing -against the computer. - -The computer must select a word at random from the list of words in the file -`/usr/share/dict/words`. This file exists on your computer already. - -The game must be interactive; the flow of the game should go as follows: - -1. At the start of the game, let the user know how many letters the computer's -word contains. - -2. Ask the user to supply one guess (i.e. letter) per round. This letter can be -upper or lower case and it should not matter. Assume the user will only submit -one letter (see **Hard Mode** for more on this.) - -3. Let the user know if their guess appears in the computer's word. - -4. Display the partially guessed word, as well as letters that have not been -guessed. For example, if the word is BOMBARD and the letters guessed are a, b, -and d, the screen should display: - -``` -B _ _ B A _ D -``` - -A user is allowed 8 guesses. Remind the user of how many guesses they have left -after each round. - -*A user loses a guess only when they guess incorrectly.* If they guess a letter -that is in the computer's word, they do not lose a guess. - -If the user guesses the same letter twice, do not take away a guess. Instead, -print a message letting them know they've already guessed that letter and ask -them to try again. - -The game should end when the user constructs the full word or runs out of -guesses. If the player runs out of guesses, reveal the word to the user when -the game ends. - -## Hard Mode - -In addition to the requirements from **Normal Mode**: - -1. Add error-checking to the program. If a user enters more than one letter, -tell them the input is invalid and let them try again. - -2. Let the user choose a level of difficulty at the beginning of the program. -Easy mode only has words of 4-6 characters; normal mode only has words of 6-10 -characters; hard mode only has words of 10+ characters. - -3. Add a loop so that when a game ends, the user is asked if they want to play -again and the game begins again if they reply in the positive. - -## Nightmare Mode - -**Option 1**: - -Use the [PyGame](http://pygame.org/news.html) or [Kivy](http://kivy.org/) -libraries to make this a graphical experience. - -**Option 2**: - -Implement the [evil version of this game](http://nifty.stanford.edu/2011/schwarz-evil-hangman/). - -## Notes - -This is the first assignment where you are writing the tests. That makes it -extra challenging. - -When testing, keep in mind that testing user input and output is hard. Testing -functions that have no side-effects -- that is, they take some arguments and -return a value without getting information from `input()` or using `random` -- -is much easier. Try to keep all your logic in _pure functions_ and then have an -outer crust of functions that talk to the user or read from files surrounding -your delicious pure function middle. If you are able to do this, you will not -need to test that outer crust. - -### Installing PyGame - -PyGame is not a normal library. If you really want to try it, run the -following: - -```sh -brew install hg sdl sdl_image sdl_mixer sdl_ttf portmidi -pip install hg+http://bitbucket.org/pygame/pygame -``` - -## Additional Resources - -* [pytest](http://pytest.org/latest/). -* [Working with Text Files](https://opentechschool.github.io/python-data-intro/core/text-files.html) - -## Credit - -This lab is based off a similar exercise in MIT's 6.00.1x course. diff --git a/mystery_word.py b/mystery_word.py new file mode 100644 index 0000000..e9bf0cb --- /dev/null +++ b/mystery_word.py @@ -0,0 +1,232 @@ +import random +import string + +with open('/usr/share/dict/words', 'r') as source: + wordlist = source.read().lower().split() + + +def choose_word(wordlist): + ''' + Returns a random word from wordlist + ''' + return random.choice(wordlist) + + +def is_word_guessed(secret_word, letters_guessed): + ''' + secret_word: string / the word the user is guessing + letters_guessed: list / which letters have been guessed so far + returns: boolean / True if all the letters of secret_word + are in letters_guessed; False otherwise + ''' + guessed = True + letter = 0 + for letter in range(len(secret_word)): + if secret_word[letter] not in letters_guessed: + guessed = False + break + return guessed + + +def get_guesssed_word(secret_word, letters_guessed): + ''' + secret_word: string / the word the user is guessing + letters_guessed: list / which letters have been guessed + returns: string /letters and underscores that shows + which letters in secret_word have been guessed so far + ''' + letter = 0 + guessed_word = '' + for letter in range(len(secret_word)): + if secret_word[letter] in letters_guessed: + guessed_word = guessed_word + (secret_word[letter] + ' ') + else: + guessed_word = guessed_word + ('_ ') + return guessed_word + + +def get_available_letters(letters_guessed): + ''' + letters_guessed: list / which letters have been guessed + returns: string / letters that represents which letters have not + yet been guessed. + ''' + availableLetters = string.ascii_lowercase + for letter in letters_guessed: + if letter in availableLetters: + remover = availableLetters.partition(letter) + availableLetters = remover[0] + remover[2] + return availableLetters + + +def mystery_word(secret_word): + ''' + secret_word: string / the word the user is guessing + + ''' + + guesses = 8 + letters_guessed = [] + winner = False + valid_characters = 'abcdefghijklmnopqrstuvwxyz' + + print(''' + ************************************** + * M Y S T E R Y W O R D * + ************************************** + ''') + print('Try to guess a word that is ' + str(len(secret_word)) + + ' letters long.') + + while guesses > 0 and winner is False: + print('~~~~~~~~~~~~~~~~~~~~~~~') + print('You have ' + str(guesses) + ' guesses left!') + print('Available Letters Remaining: ' + + get_available_letters(letters_guessed)) + guess = input('Guess a letter: ') + guess = guess.lower() + if len(guess) != 1: + print('Please enter a single letter!') + elif valid_characters.find(guess) < 0: + print('Please enter a valid letter!') + elif guess not in get_available_letters(letters_guessed): + print("Whoops! You've already guessed that letter. Try again: " + + get_guesssed_word(secret_word, letters_guessed)) + elif guess not in secret_word: + letters_guessed.append(guess) + print('Nope! That letter is not in my word! ' + + get_guesssed_word(secret_word, letters_guessed)) + guesses -= 1 + elif guess in secret_word: + letters_guessed.append(guess) + print('Great guess! ' + + get_guesssed_word(secret_word, letters_guessed)) + if is_word_guessed(secret_word, letters_guessed): + winner = True + + print('~~~~~~~~~~~~~~~~~~~~~~~') + if winner is True: + print(''' + + Congrats! You WON! + + + : :M + XMX .HMM> + MMMM. dMMMM> + 'MMMMMX ..... dMMMMMMX + XMMMMMMMnMMMMMMMMMMMMMMMMMMM + :MMMMMMMMMMMMMMMMMMMMMMMMMMMM> + XMMMMM!' 'MMMMMM'` `'MMMMM + MMMM# 4MMf `MMMX + XMMM MX 'MMM: + 'MMM~ '> MMM + MMMf . '> `MMX + MMMM> :MMM '> :MMM MMMX + XMMMM MMMM> '> XMMMX MMMMk + MMMMMM> MMMM~ 'k MMMMX MMMMMh + MMMMMMMX XMMM XX ?MMM XMMMMMMM + MMMMMMMMk ^` X 'h ` :MM##MMM~ + ?MM> ^?M. .! %. .HM' MM + .?M ''%+++!'.nMMMMn '%++!*' %.. 'M.. + `?M>+$L : XM' + 'X % XMMMMMMMM> X 'f + X `M. ?MMMMMM~ .HM :` + %. `MMMx. .xHMMM X + .. `X `MMMMMMMMMMMMMMMMMMM :f + :MMMMMMMh:.M. 4MM ' MM' xMMMMMMMMMMh. + :MMMMMMMMMMMMMMM: `'x.......x'`.HMMMMMMMMMMMMMM + .MMMMMMMMMMMMMMMMMMMMhx.......xHMMMMMMMMMMMMMMMMM + .nHMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM`MMMMMMMMMMMMMMMMX + :MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMdMMMMMMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMMMMMM'``''MMMMMMMMMMMM!MMMMMMMMMMMMMMMMMMMM~ +MMMMMMMMMMMMMMMMMMM! XMMMMMMMMMMMf:HMMMMMMMMMMMMMMMMM! +M?MMMMMMMMMMMMMMMM` :MMMMMMMMMMMM!MMMMMMMMMMMMMMMMMMM~ +:MMMMMMMMMMMMMMMMX MMMMMMMMMMMMXXMMMMMMMMMMMMMMMMM` +MMMMMMMMMMMMMMMMMX 'MMMMMMMMMMMMM!MMMMMMMMMMMMMMMMX +MMMMMMMMMMMMMMMMM~ 'MMMMMMMMMMMMMM?MMMMMMMMMMMMMMM~ + #M)MMMMMMMM!MMM MMMMMMMMMMMMMMMM/MMMMMMMMMMMM~ + ?MMMMMM'-'2MMMMMx XMMMMMMMMMMMMMMMMX?**!:MMM'` + ^'' XMMMMMMMM 'MMMMMMMMMMM'`MMMMMMMMMMM> + XMMMMMMMMML MMMMMMMMMX .MMMMMMMMMMMf + XMMMMMMMMMML 4MMMMMMMMMXMMMMMMMMMMM~ + XMMMMMMMMMMMMXMMMMMMMMMMXMMMMMMMMMx. + MMMMMMMMMMMMM!MMMMMMMMMMLMMMMMMMMMMMMx + #MMMMMMMMMMMMMMMMMMMMMMM!MMMMMMMMMMMMM + `MMMMMMMMMMMLMMMMMMMMMMM/MMMMMMMMMMMM> + `*MMMMM!nMMMMMHh(?*MMM?MMMMMMMMMMM> + XMMMMMMMMMMMMMMMX4MMMMMMMMMM + XM# `*MMMMMMMMXMMMMMMMM' + 'M `MMMMMMMX^'*'' + Xf !?MMMMMM + 'X X ?MMMMM + ! `> `MMMMX + #: 4 X> 'MMMM> + `L 'x.xM~ `MMMX + %. f MMMX + `#M`` :MMM~ + `Mx. dMMM~ + ``'**MM* + ''') + else: + print('Sorry, the word was ' + secret_word + '.' + ''' + + + + ,;|||||\ ____________ + ___ |;|||:;:| ,' You |---. + /;,a.\ \ |||||...._ `-. _ LOSE! ; + |||@@@\ \ __----,'......~\_ ,---._ ;; `-._______,' + |||@@@@\ \,-~~~~::::::,'... _.----\_,' `. ' + |||;aaa/,;;;;:::::::::: _.-': ;...._ ; + `::||||;;;;:::::::::::' `--' ,;;:::::~:~~----._____ + ;;;;;::::::::::::`-. ,;::::::::::::::::::::::::___ + |;;;;;:::::::::::::::`---;:::::::::::::::::::'.,-/~~ ~~\-._ + |;;;;;;;;:::::::::::::::::::::::::::::::::',-' `\ | /'. : + `-:;;;;;;;;;;::::::::::::::::::::::::::::; . . `\:/' . . ; + `~--;;;;;;;;;;;;::::::::::::::::::::::: . . | ,' + `~~~~--;;;;;;;;;;;;::::::::::::::::`.. _/' `\_/'; + `~~.;;;;;::::::::::::::::::::::---' . .. ,' + ~~;.....;'~~~`---.:::::::::: ,' + :;;;::: ~~~~~~`---`-.____,' + `|;;:::: + |;;::::: ........... + |;;::::: .::::::::::|||:. + ___||::::::: ___ .|||| `:||| + /':::`|::::::|':::`\ .|||| |||| + /::::::||/@@@\::::::::\ |||| |||| + /::::::||:@@@@@@@\::::::\ ||||__ |||| + /::::::|||@@@@@@@@@|::::::\ |`.`--) |||| + /::::::;||:@@@@@@@@@|:::::::\ \_~_/ ,|||| + /:::::;;|||:@@@@@@@@@@|\::::::\ ||||' + /:::::;;;||::@@@@@@@@@@| \::::::\ |||| + /:::::;; |||:@@@@@@@@@@@@| \::::::\ ||||. + /:::::;; |||:@@@@@@@@@@@@|. \::::::\ `|||| + ,'::::;; |||::@@@@@@@@@@@@|| \::::::\___ |||| + ,:::::;; |||::@@@@@@@@@@@|:| \;,'~~'_ `-. ,|||| + ,:::::;; ||::@@@@@@@@@@@@|:| ,' ~~ `._ `. ,||||' + ,::::;;; |||::_--._@@@@@@|::| ,' __ `._| .||||' + ,:::::;; ;~~~' ~--.__|::|; ' `-. ; ||||' + ,::::;;; ,' ::::::::~~--;__ `_,' ||||| + ,:::::;; ,' (~--::::::::::: ~~-._ _;\ `||||| + ,:::::;/ ,' _______-.-----~~~-._ :::::: `--' ;;\ `||||| + |:::::/ ____.-:::::::::::::::::::,-~-.::::::::::::::) .||||' + |:::::`~':::::::::::::::::::.--'|::::| `~~~~~--.__.-' ||||' + `::::::::::::::::___----~~~~@@@@|::::| .|||||' + `--____,---~~~~~ @@@@@@@@@@@|:::::| ,||||.' + ; `.@@@@@@@@@@|:::::| ,||||||.' + | : : ;@@@@@@@@@@|:::::| ,|||||||.' + `._;.__;`-._,'@@@@@@@@@@|:::::| ,|||||||'~~ + |:@@@@@@@@@@@@@@|:::::::| ,||||||'~ + |:@@@@@@@@@@@@@@|:::::::| ||||||' + =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + ''') + + +'''ASCII art found at: http://www.asciiworld.com/''' + + +secret_word = choose_word(wordlist).lower() +mystery_word(secret_word) diff --git a/requirements.txt b/requirements.txt index e079f8a..5a1fcbf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,5 @@ -pytest +import pytest, random, string + +Must be able to pull a word from the Mac OS dictionary: + +/usr/share/dict/words \ No newline at end of file diff --git a/tests/mystery_word.py b/tests/mystery_word.py new file mode 100644 index 0000000..e9bf0cb --- /dev/null +++ b/tests/mystery_word.py @@ -0,0 +1,232 @@ +import random +import string + +with open('/usr/share/dict/words', 'r') as source: + wordlist = source.read().lower().split() + + +def choose_word(wordlist): + ''' + Returns a random word from wordlist + ''' + return random.choice(wordlist) + + +def is_word_guessed(secret_word, letters_guessed): + ''' + secret_word: string / the word the user is guessing + letters_guessed: list / which letters have been guessed so far + returns: boolean / True if all the letters of secret_word + are in letters_guessed; False otherwise + ''' + guessed = True + letter = 0 + for letter in range(len(secret_word)): + if secret_word[letter] not in letters_guessed: + guessed = False + break + return guessed + + +def get_guesssed_word(secret_word, letters_guessed): + ''' + secret_word: string / the word the user is guessing + letters_guessed: list / which letters have been guessed + returns: string /letters and underscores that shows + which letters in secret_word have been guessed so far + ''' + letter = 0 + guessed_word = '' + for letter in range(len(secret_word)): + if secret_word[letter] in letters_guessed: + guessed_word = guessed_word + (secret_word[letter] + ' ') + else: + guessed_word = guessed_word + ('_ ') + return guessed_word + + +def get_available_letters(letters_guessed): + ''' + letters_guessed: list / which letters have been guessed + returns: string / letters that represents which letters have not + yet been guessed. + ''' + availableLetters = string.ascii_lowercase + for letter in letters_guessed: + if letter in availableLetters: + remover = availableLetters.partition(letter) + availableLetters = remover[0] + remover[2] + return availableLetters + + +def mystery_word(secret_word): + ''' + secret_word: string / the word the user is guessing + + ''' + + guesses = 8 + letters_guessed = [] + winner = False + valid_characters = 'abcdefghijklmnopqrstuvwxyz' + + print(''' + ************************************** + * M Y S T E R Y W O R D * + ************************************** + ''') + print('Try to guess a word that is ' + str(len(secret_word)) + + ' letters long.') + + while guesses > 0 and winner is False: + print('~~~~~~~~~~~~~~~~~~~~~~~') + print('You have ' + str(guesses) + ' guesses left!') + print('Available Letters Remaining: ' + + get_available_letters(letters_guessed)) + guess = input('Guess a letter: ') + guess = guess.lower() + if len(guess) != 1: + print('Please enter a single letter!') + elif valid_characters.find(guess) < 0: + print('Please enter a valid letter!') + elif guess not in get_available_letters(letters_guessed): + print("Whoops! You've already guessed that letter. Try again: " + + get_guesssed_word(secret_word, letters_guessed)) + elif guess not in secret_word: + letters_guessed.append(guess) + print('Nope! That letter is not in my word! ' + + get_guesssed_word(secret_word, letters_guessed)) + guesses -= 1 + elif guess in secret_word: + letters_guessed.append(guess) + print('Great guess! ' + + get_guesssed_word(secret_word, letters_guessed)) + if is_word_guessed(secret_word, letters_guessed): + winner = True + + print('~~~~~~~~~~~~~~~~~~~~~~~') + if winner is True: + print(''' + + Congrats! You WON! + + + : :M + XMX .HMM> + MMMM. dMMMM> + 'MMMMMX ..... dMMMMMMX + XMMMMMMMnMMMMMMMMMMMMMMMMMMM + :MMMMMMMMMMMMMMMMMMMMMMMMMMMM> + XMMMMM!' 'MMMMMM'` `'MMMMM + MMMM# 4MMf `MMMX + XMMM MX 'MMM: + 'MMM~ '> MMM + MMMf . '> `MMX + MMMM> :MMM '> :MMM MMMX + XMMMM MMMM> '> XMMMX MMMMk + MMMMMM> MMMM~ 'k MMMMX MMMMMh + MMMMMMMX XMMM XX ?MMM XMMMMMMM + MMMMMMMMk ^` X 'h ` :MM##MMM~ + ?MM> ^?M. .! %. .HM' MM + .?M ''%+++!'.nMMMMn '%++!*' %.. 'M.. + `?M>+$L : XM' + 'X % XMMMMMMMM> X 'f + X `M. ?MMMMMM~ .HM :` + %. `MMMx. .xHMMM X + .. `X `MMMMMMMMMMMMMMMMMMM :f + :MMMMMMMh:.M. 4MM ' MM' xMMMMMMMMMMh. + :MMMMMMMMMMMMMMM: `'x.......x'`.HMMMMMMMMMMMMMM + .MMMMMMMMMMMMMMMMMMMMhx.......xHMMMMMMMMMMMMMMMMM + .nHMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM`MMMMMMMMMMMMMMMMX + :MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMdMMMMMMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMMMMMM'``''MMMMMMMMMMMM!MMMMMMMMMMMMMMMMMMMM~ +MMMMMMMMMMMMMMMMMMM! XMMMMMMMMMMMf:HMMMMMMMMMMMMMMMMM! +M?MMMMMMMMMMMMMMMM` :MMMMMMMMMMMM!MMMMMMMMMMMMMMMMMMM~ +:MMMMMMMMMMMMMMMMX MMMMMMMMMMMMXXMMMMMMMMMMMMMMMMM` +MMMMMMMMMMMMMMMMMX 'MMMMMMMMMMMMM!MMMMMMMMMMMMMMMMX +MMMMMMMMMMMMMMMMM~ 'MMMMMMMMMMMMMM?MMMMMMMMMMMMMMM~ + #M)MMMMMMMM!MMM MMMMMMMMMMMMMMMM/MMMMMMMMMMMM~ + ?MMMMMM'-'2MMMMMx XMMMMMMMMMMMMMMMMX?**!:MMM'` + ^'' XMMMMMMMM 'MMMMMMMMMMM'`MMMMMMMMMMM> + XMMMMMMMMML MMMMMMMMMX .MMMMMMMMMMMf + XMMMMMMMMMML 4MMMMMMMMMXMMMMMMMMMMM~ + XMMMMMMMMMMMMXMMMMMMMMMMXMMMMMMMMMx. + MMMMMMMMMMMMM!MMMMMMMMMMLMMMMMMMMMMMMx + #MMMMMMMMMMMMMMMMMMMMMMM!MMMMMMMMMMMMM + `MMMMMMMMMMMLMMMMMMMMMMM/MMMMMMMMMMMM> + `*MMMMM!nMMMMMHh(?*MMM?MMMMMMMMMMM> + XMMMMMMMMMMMMMMMX4MMMMMMMMMM + XM# `*MMMMMMMMXMMMMMMMM' + 'M `MMMMMMMX^'*'' + Xf !?MMMMMM + 'X X ?MMMMM + ! `> `MMMMX + #: 4 X> 'MMMM> + `L 'x.xM~ `MMMX + %. f MMMX + `#M`` :MMM~ + `Mx. dMMM~ + ``'**MM* + ''') + else: + print('Sorry, the word was ' + secret_word + '.' + ''' + + + + ,;|||||\ ____________ + ___ |;|||:;:| ,' You |---. + /;,a.\ \ |||||...._ `-. _ LOSE! ; + |||@@@\ \ __----,'......~\_ ,---._ ;; `-._______,' + |||@@@@\ \,-~~~~::::::,'... _.----\_,' `. ' + |||;aaa/,;;;;:::::::::: _.-': ;...._ ; + `::||||;;;;:::::::::::' `--' ,;;:::::~:~~----._____ + ;;;;;::::::::::::`-. ,;::::::::::::::::::::::::___ + |;;;;;:::::::::::::::`---;:::::::::::::::::::'.,-/~~ ~~\-._ + |;;;;;;;;:::::::::::::::::::::::::::::::::',-' `\ | /'. : + `-:;;;;;;;;;;::::::::::::::::::::::::::::; . . `\:/' . . ; + `~--;;;;;;;;;;;;::::::::::::::::::::::: . . | ,' + `~~~~--;;;;;;;;;;;;::::::::::::::::`.. _/' `\_/'; + `~~.;;;;;::::::::::::::::::::::---' . .. ,' + ~~;.....;'~~~`---.:::::::::: ,' + :;;;::: ~~~~~~`---`-.____,' + `|;;:::: + |;;::::: ........... + |;;::::: .::::::::::|||:. + ___||::::::: ___ .|||| `:||| + /':::`|::::::|':::`\ .|||| |||| + /::::::||/@@@\::::::::\ |||| |||| + /::::::||:@@@@@@@\::::::\ ||||__ |||| + /::::::|||@@@@@@@@@|::::::\ |`.`--) |||| + /::::::;||:@@@@@@@@@|:::::::\ \_~_/ ,|||| + /:::::;;|||:@@@@@@@@@@|\::::::\ ||||' + /:::::;;;||::@@@@@@@@@@| \::::::\ |||| + /:::::;; |||:@@@@@@@@@@@@| \::::::\ ||||. + /:::::;; |||:@@@@@@@@@@@@|. \::::::\ `|||| + ,'::::;; |||::@@@@@@@@@@@@|| \::::::\___ |||| + ,:::::;; |||::@@@@@@@@@@@|:| \;,'~~'_ `-. ,|||| + ,:::::;; ||::@@@@@@@@@@@@|:| ,' ~~ `._ `. ,||||' + ,::::;;; |||::_--._@@@@@@|::| ,' __ `._| .||||' + ,:::::;; ;~~~' ~--.__|::|; ' `-. ; ||||' + ,::::;;; ,' ::::::::~~--;__ `_,' ||||| + ,:::::;; ,' (~--::::::::::: ~~-._ _;\ `||||| + ,:::::;/ ,' _______-.-----~~~-._ :::::: `--' ;;\ `||||| + |:::::/ ____.-:::::::::::::::::::,-~-.::::::::::::::) .||||' + |:::::`~':::::::::::::::::::.--'|::::| `~~~~~--.__.-' ||||' + `::::::::::::::::___----~~~~@@@@|::::| .|||||' + `--____,---~~~~~ @@@@@@@@@@@|:::::| ,||||.' + ; `.@@@@@@@@@@|:::::| ,||||||.' + | : : ;@@@@@@@@@@|:::::| ,|||||||.' + `._;.__;`-._,'@@@@@@@@@@|:::::| ,|||||||'~~ + |:@@@@@@@@@@@@@@|:::::::| ,||||||'~ + |:@@@@@@@@@@@@@@|:::::::| ||||||' + =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + ''') + + +'''ASCII art found at: http://www.asciiworld.com/''' + + +secret_word = choose_word(wordlist).lower() +mystery_word(secret_word) diff --git a/tests/test_mystery.py b/tests/test_mystery.py new file mode 100644 index 0000000..cf56e20 --- /dev/null +++ b/tests/test_mystery.py @@ -0,0 +1,29 @@ +'''Incomplete tests as I need more understanding on tests''' + +import mystery_word as mw + +def test_choose_word(): + word = mw.choose_word() + assert word is not None + +@pytest.fixture +def setup(): + secret_word = 'testing' + mw.letters_guessed = [] + + +def test_is_word_guessed(setup): + assert mw.check_letter('t') + assert not mw.check_letter('x') + +'''def test_get_guessed_word(setup): + assert + +def test_get_available_letters(setup): + assert + +@pytest.mark.parametrize("input,expected", []) +def test_mystery_word(setup): + assert eval(input) == expected + assert +''' From c4cc50e5c72ed0911dabddc0bfc2dfe1bcd6ee57 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Tue, 20 Jan 2015 08:53:23 -0500 Subject: [PATCH 2/2] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index f9aa298..a0b0db9 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,23 @@ Introduction + This app works and passes pep8 specs. The test file is incomplete because I don’t quite understand testing at this point. Documentation + This is a Mystery Word game. The user has 8 guesses to guess a word given at random. Setup + 1. Git or download this folder 2. Run this program in Terminal: python mystery_word.py 3. Run test using: py.test test_mystery.py 4. Enjoy Requirements + Have Python 3 installed on your computer Acknowledgements + The included ASCII art was found at http://www.asciiworld.com for endgame graphics