Skip to content

Commit 9f6d1cf

Browse files
Merge pull request 4GeeksAcademy#47 from kiddopro/19-Bottles-Of-Milk
19-Bottles-Of-Milk
2 parents cca07cb + 8eb16fc commit 9f6d1cf

File tree

1 file changed

+13
-1
lines changed
  • exercises/19-Bottles-Of-Milk

1 file changed

+13
-1
lines changed

exercises/19-Bottles-Of-Milk/test.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ def test_function_spin_chamber(capsys, app):
1414
except AttributeError:
1515
raise AttributeError("The function number_of_bottles should exist")
1616

17+
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
18+
content = f.readlines()
19+
my_funcCall = [s for s in content if "def number_of_bottles():" in s]
20+
my_funcCallVar = content.index(my_funcCall[0])
21+
regex = r"def number_of_bottles\(\):"
22+
assert re.match(regex, content[my_funcCallVar])
23+
my_printCall = [s for s in content[3:] if "number_of_bottles()" in s]
24+
my_printCallVar = content.index(my_printCall[0])
25+
regex = r"number_of_bottles\(\)"
26+
assert re.match(regex, content[my_printCallVar])
27+
1728
@pytest.mark.it('The function must return the expected output')
1829
def test_for_function_output(capsys):
1930
number_of_bottles()
@@ -28,5 +39,6 @@ def test_for_function_output(capsys):
2839
text+=("2 bottles of milk on the wall, 2 bottles of milk. Take one down and pass it around, 1 bottle of milk on the wall.\n")
2940
else:
3041
text+=(str(x) + " bottles of milk on the wall, " + str(x) + " bottles of milk. Take one down and pass it around, " + str(x-1)+ " bottles of milk on the wall.\n")
31-
assert captured.out == text
42+
43+
assert captured.out == text
3244

0 commit comments

Comments
 (0)