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

issue273 fix #291

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
28 changes: 22 additions & 6 deletions taqueria/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,56 @@ def test_basic_order():
"""input of \"taco\", \"taco\", and \"tortilla salad\" results in $14.00"""
items = ["taco", "taco", "tortilla salad"]
output = 14.0
check50.run("python3 taqueria.py").stdin(items[0], prompt=True).stdin(items[1], prompt=True).stdin(items[2], prompt=True).stdout(regex(f"{output:.2f}"), f"${output:.2f}", regex=True).kill()
check50.run("python3 taqueria.py").stdin(items[0], prompt=True).stdin(
items[1], prompt=True
).stdin(items[2], prompt=True).stdout(
regex(f"{output:.2f}"), f"${output:.2f}", regex=True
).kill()


@check50.check(test_EOF)
def test_basic_order_2():
"""input of \"burrito\", \"bowl\", and \"nachos\" results in $27.00"""
items = ["burrito", "bowl", "nachos"]
output = 27.0
check50.run("python3 taqueria.py").stdin(items[0], prompt=True).stdin(items[1], prompt=True).stdin(items[2], prompt=True).stdout(regex(f"{output:.2f}"), f"${output:.2f}", regex=True).kill()
check50.run("python3 taqueria.py").stdin(items[0], prompt=True).stdin(
items[1], prompt=True
).stdin(items[2], prompt=True).stdout(
regex(f"{output:.2f}"), f"${output:.2f}", regex=True
).kill()


@check50.check(test_EOF)
def test_basic_order_3():
"""input of \"Baja Taco\", \"Quesadilla\", and \"Super Burrito\" results in $21.00"""
items = ["Baja Taco", "Quesadilla", "Super Burrito"]
output = 21.0
check50.run("python3 taqueria.py").stdin(items[0], prompt=True).stdin(items[1], prompt=True).stdin(items[2], prompt=True).stdout(regex(f"{output:.2f}"), f"${output:.2f}", regex=True).kill()
check50.run("python3 taqueria.py").stdin(items[0], prompt=True).stdin(
items[1], prompt=True
).stdin(items[2], prompt=True).stdout(
regex(f"{output:.2f}"), f"${output:.2f}", regex=True
).kill()


@check50.check(test_EOF)
def test_capitalization():
"""input of \"Super quesadilla\" results in $9.50"""
input = "Super quesadilla"
output = 9.50
check50.run("python3 taqueria.py").stdin(input, prompt=True).stdout(regex(f"{output:.2f}"), f"${output:.2f}", regex=True).kill()
check50.run("python3 taqueria.py").stdin(input, prompt=True).stdout(
regex(f"{output:.2f}"), f"${output:.2f}", regex=True
).kill()


@check50.check(test_EOF)
def test_invalid_order():
"""input of \"burger\" results in reprompt"""
input = "burger"
check50.run("python3 taqueria.py").stdin(input, prompt=True).reject()
check50.run("python3 taqueria.py").stdin(input, prompt=True).stdout(
r"(?<!\n)Item: ", "Item: "
).kill()


def regex(cost):
"""match case-insensitively with dollar-sign required and only characters on either side"""
return fr'(?i)^[\D]*\${escape(cost)}[\D]*$'
return rf"(?i)^[\D]*\${escape(cost)}[\D]*$"