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
33 changes: 29 additions & 4 deletions exercises/08-Your-First-If/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,47 @@ def test_for_print(capsys):
assert bool(regex.search(content)) == True

@pytest.mark.it("When input for more than 100 it should print: Give me your money!")
def test_for_more(stdin, capsys, app):
def test_for_output_when_101(stdin, capsys, app):
with mock.patch('builtins.input', lambda x: 101):
app()
captured = capsys.readouterr()
assert "Give me your money!\n" == captured.out

@pytest.mark.it("When input exactly 100 should print: Buy me some coffee you cheap ")
def test_between(capsys, app):
def test_for_output_when_100(capsys, app):
with mock.patch('builtins.input', lambda x: 100):
app()
captured = capsys.readouterr()
assert "Buy me some coffee you cheap!\n" == captured.out

@pytest.mark.it("When input is 99 should print: Buy me some coffee you cheap ")
def test_for_output_when_99(capsys, app):
with mock.patch('builtins.input', lambda x: 99):
app()
captured = capsys.readouterr()
assert "Buy me some coffee you cheap!\n" == captured.out

@pytest.mark.it("When input is 51 should print: Buy me some coffee you cheap ")
def test_for_output_when_51(capsys, app):
with mock.patch('builtins.input', lambda x: 51):
app()
captured = capsys.readouterr()
assert "Buy me some coffee you cheap!\n" == captured.out

@pytest.mark.it("When input exactly 50 should print: You are a poor guy, go away")
def test_for_less(capsys, app):
def test_for_output_when_50(capsys, app):
with mock.patch('builtins.input', lambda x: 50):
app()
captured = capsys.readouterr()
assert "You are a poor guy, go away!\n" == captured.out
assert "You are a poor guy, go away!\n" == captured.out

@pytest.mark.it("When input less than 50 should print: You are a poor guy, go away")
def test_for_output_when_49(capsys, app):
with mock.patch('builtins.input', lambda x: 49):
app()
captured = capsys.readouterr()
assert "You are a poor guy, go away!\n" == captured.out