Пример #1
0
def test_alice_tries_word_madness():
    # Alice tries word madness for the first time and makes a silly story
    story = "Mary had a little { animal }."

    # Alice loads up a story
    madness = Madness()
    madness.story = story

    # Madness prompts her for a word to fill in
    prompts = madness.get_prompts()
    assert 1 == len(prompts)
    assert prompts[0].text == "animal"

    # Alice returns the word
    prompts[0].value = "goat"

    # The completed story is output for her.
    expected = "Mary had a little goat."
    assert expected == madness.ensue_hilarity()
#!/usr/bin/python3

import sys
from os.path import join
from os import getcwd

from madness.madness import Madness

story = sys.argv[1]
cwd = getcwd()

# Get the story text
story_path = join(cwd, "stories", story)
f = open(story_path, "rb")
text = f.read()
f.close()

# Read story and get prompts
builder = Madness()
builder.story = text.decode()
prompts = builder.get_prompts()

for prompt in prompts:
    prompt.value = input("Enter {0}: ".format(prompt.text))

print("\n------Your Story------\n\n")
print(builder.ensue_hilarity())