From 08b0d8ca47dd8bb968b320ddf779aead5f325cd5 Mon Sep 17 00:00:00 2001 From: kamilkrzyskow Date: Fri, 19 Aug 2022 03:51:59 +0200 Subject: [PATCH] modified `meal` --- meal/__init__.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/meal/__init__.py b/meal/__init__.py index 2c29ccb9..b6d5ec88 100644 --- a/meal/__init__.py +++ b/meal/__init__.py @@ -25,6 +25,16 @@ 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" @@ -32,7 +42,7 @@ def test_lunch(): 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" @@ -40,7 +50,7 @@ def test_lunch(): 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" @@ -48,14 +58,6 @@ def test_dinner(): 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*$' \ No newline at end of file