def test_prompts_list2(): expected = [ '{Adjective}', '{Adjective}', '{A First Name}', '{Past Tense Verb}', '{A First Name}', '{Adjective}', '{Adjective}', '{Plural Noun}', '{Large Animal}', '{Small Animal}', "{A Girl's Name}", '{Adjective}', '{Plural Noun}', '{Adjective}', '{Plural Noun}', '{Number 1-50}', "{First Name's}", '{Number}', '{Plural Noun}', '{Number}', '{Plural Noun}' ] actual = prompts_list('\{[a-zA-Z0-9\' -]*\}', read_file('template_madlib.txt')) assert actual == expected
def test_read_file(): """testing if read_file pathway works""" contents = madlib.read_file('./data.txt') assert contents.startswith('Make Me A Video Game!')
def test_write_file(): expected = "\nHere is your story:\n-------------------\n\nI the 1 and 1 1 have 11's 1 sister and plan to steal her 1 1!\n\nWhat are a 1 and backpacking 1 to do? Before you can help 1, you'll have to collect the 1 1 and 1 1 that open up the 1 worlds connected to A 1 Lair. There are 1 1 and 1 1 in the game, along with hundreds of other goodies for you to find.\n" expected2 = "\nHere is your story:\n-------------------\n\nI the and have 's sister and plan to steal her !\n\nWhat are a and backpacking to do? Before you can help , you'll have to collect the and that open up the worlds connected to A Lair. There are and in the game, along with hundreds of other goodies for you to find.\n" actual = read_file('madlib_result.txt') assert actual == expected or expected2
def test_read(): expected = 'test {one} test {two} test {three}\n' actual = read_file('file_test.txt') assert actual == expected
def test_empty_template2(): expected = "Make Me A Video Game!\n\nI the {} and {} {} have {}{}'s {} sister and plan to steal her {} {}!\n\nWhat are a {} and backpacking {} to do? Before you can help {}, you'll have to collect the {} {} and {} {} that open up the {} worlds connected to A {} Lair. There are {} {} and {} {} in the game, along with hundreds of other goodies for you to find.\n" actual = empty_template('\{[a-zA-Z0-9\' -]*\}', read_file('template_madlib.txt')) assert actual == expected
def test_read_file(): """To test read_file to make sure the output is correct.""" contents = madlib.read_file('./infile.txt') assert contents.startswith('Make Me A Video Game!\n')
def test_read_file(): contents = madlib.read_file('./madlib_raw.txt') assert contents.startswith('Make Me A Video Game!')
def test_file_reader(): expected = "In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to eat: it was a hobbit-hole, and that means comfort." actual = read_file("4tests.txt") assert actual == expected
def test_read_file(): with open(test_file) as f: expected = read_file(test_file) actual = f.read() assert expected == actual