Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion exercises/19-Bottles-Of-Milk/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ def test_function_spin_chamber(capsys, app):
except AttributeError:
raise AttributeError("The function number_of_bottles should exist")

f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
content = f.readlines()
my_funcCall = [s for s in content if "def number_of_bottles():" in s]
my_funcCallVar = content.index(my_funcCall[0])
regex = r"def number_of_bottles\(\):"
assert re.match(regex, content[my_funcCallVar])
my_printCall = [s for s in content[3:] if "number_of_bottles()" in s]
my_printCallVar = content.index(my_printCall[0])
regex = r"number_of_bottles\(\)"
assert re.match(regex, content[my_printCallVar])

@pytest.mark.it('The function must return the expected output')
def test_for_function_output(capsys):
number_of_bottles()
Expand All @@ -28,5 +39,6 @@ def test_for_function_output(capsys):
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")
else:
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")
assert captured.out == text

assert captured.out == text