-
Notifications
You must be signed in to change notification settings - Fork 2
/
lab07_student_tests.py
69 lines (46 loc) · 1.46 KB
/
lab07_student_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# lab07_student_tests.py - Tests for CS8 lab07
import pytest
'''
You should write your own test cases using pytest.
Here are some examples for each function to test:
'''
from lab07 import createWordList
#### Write tests for createWordList ####
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])
def test_createWordList_1():
assert False
#...
from lab07 import canWeMakeIt
#### Write tests for canWeMakeIt ####
def test_canWeMakeIt_0():
# Example Test
assert(canWeMakeIt('ape','pae') == True)
def test_canWeMakeIt_1():
assert False
#...
#### Write tests for getWordPoints ####
from lab07 import getWordPoints
letterPoints = {'a':1, 'b':3, 'c':3, 'd':2, 'e':1, 'f':4,\
'g':2, 'h':4, 'i':1, 'j':8, 'k':5, 'l':1,\
'm':3, 'n':1, 'o':1, 'p':3, 'q':10, 'r':1,\
's':1, 't':1, 'u':1, 'v':4, 'w':4, 'x':8,\
'y':4, 'z':10}
def test_getWordPoints_0():
# Example Test
assert(getWordPoints('ape',letterPoints) == 5)
def test_getWordPoints_1():
assert False
#...