Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified meal #135

Open
wants to merge 1 commit into
base: 2022/python
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions meal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,39 @@ def test_breakfast2():


@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(exists)
@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(exists)
@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()


@check50.check(exists)
def test_no_output():
"""input of 11:11 yields no output"""
input = "11:11"
output = ""
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*$'