-
Notifications
You must be signed in to change notification settings - Fork 284
Expand file tree
/
Copy path__init__.py
More file actions
28 lines (21 loc) · 805 Bytes
/
__init__.py
File metadata and controls
28 lines (21 loc) · 805 Bytes
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
import check50
from re import search
@check50.check()
def exists():
"""answers.txt exists"""
check50.exists("answers.txt")
@check50.check(exists)
def answers():
"""answers all questions"""
content = open("answers.txt", "r").read()
if "TODO" in content:
raise check50.Failure("Not all questions answered.")
@check50.check(exists)
def sorts():
"""correctly identifies each sort"""
check50.log("checking that sorts are classified correctly...")
expected = ["sort1 uses:\s*[Bb][Uu][Bb][Bb][Ll][Ee]", "sort2 uses:\s*[Mm][Ee][Rr][Gg][Ee]", "sort3 uses:\s*[Ss][Ee][Ll][Ee][Cc][Tt][Ii][Oo][Nn]"]
actual = open("answers.txt", "r").read()
for e in expected:
if not search(e, actual):
raise check50.Failure("Incorrect assignment of sorts.")