-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy path__init__.py
63 lines (47 loc) · 1.81 KB
/
__init__.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
import check50
from re import escape
@check50.check()
def exists():
"""meal.py exists"""
check50.exists("meal.py")
@check50.check(exists)
def test_breakfast():
"""input of 7:00 yields output of \"breakfast time\""""
input = "7:00"
output = "breakfast time"
check50.run("python3 meal.py").stdin(input, prompt=True).stdout(regex(output), output, regex=True).exit()
@check50.check(exists)
def test_breakfast2():
"""input of 7:30 yields output of \"breakfast time\""""
input = "7:30"
output = "breakfast time"
check50.run("python3 meal.py").stdin(input, prompt=True).stdout(regex(output), output, regex=True).exit()
@check50.check(exists)
def test_no_output():
"""input of 8:01 yields no output"""
input = "8:01"
output = ""
output = str(check50.run("python3 meal.py").stdin(input, prompt=True).stdout())
if output != "":
raise check50.Mismatch("", output)
@check50.check(test_no_output)
def test_lunch():
"""input of 12:42 yields output of \"lunch time\""""
input = "12:42"
output = "lunch time"
check50.run("python3 meal.py").stdin(input, prompt=True).stdout(regex(output), output, regex=True).exit()
@check50.check(test_no_output)
def test_lunch():
"""input of 13:00 yields output of \"lunch time\""""
input = "13:00"
output = "lunch time"
check50.run("python3 meal.py").stdin(input, prompt=True).stdout(regex(output), output, regex=True).exit()
@check50.check(test_no_output)
def test_dinner():
"""input of 18:32 yields output of \"dinner time\""""
input = "18:32"
output = "dinner time"
check50.run("python3 meal.py").stdin(input, prompt=True).stdout(regex(output), output, regex=True).exit()
def regex(time):
"""match case-insensitively with only whitespace on either side"""
return fr'(?i)^\s*{escape(time)}\s*$'