Ejemplo n.º 1
0
def test_createWordList_1():
    testWords = ["cheesecake"]
    outfile = open("test_file_1.txt", "x")
    for word in testWords:
        outfile.write(word + "\n")
    outfile.close()
    testList = createWordList("test_file_1.txt")
    assert len(testList) == len(testWords)
    for i in range(len(testWords)):
        assert testWords[i] == testList[i]
Ejemplo n.º 2
0
def test_createWordList_2():
    words = ['a']
    outfile = open('test_file_2.txt', 'w')
    for item in words:
        outfile.write(item + '\n')
    outfile.close()

    newlist = createWordList('test_file_2.txt')
    assert (len(newlist) == len(words))

    for i in range(len(words)):
        assert (words[i] == newlist[i])
Ejemplo n.º 3
0
def test_createWordList_0():
    # Example test
    # Write to a file with words in it
    words = ['computer', 'science', 'python']
    outfile = open('test_file_0.txt', 'w')
    for item in words:
        outfile.write(item + '\n')
    outfile.close()

    # Read the file with words created in it to test if createWordList
    # creates a list of words correctly.
    newlist = createWordList('test_file_0.txt')
    assert (len(newlist) == len(words))

    for i in range(len(words)):
        assert (words[i] == newlist[i])