Skip to content

Commit f0809f9

Browse files
Merge pull request #45 from kiddopro/mocking_inputs
08-Your-First-If
2 parents 851cec7 + 737b704 commit f0809f9

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

exercises/08-Your-First-If/test.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,47 @@ def test_for_print(capsys):
2525
assert bool(regex.search(content)) == True
2626

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

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

41+
@pytest.mark.it("When input is 99 should print: Buy me some coffee you cheap ")
42+
def test_for_output_when_99(capsys, app):
43+
with mock.patch('builtins.input', lambda x: 99):
44+
app()
45+
captured = capsys.readouterr()
46+
assert "Buy me some coffee you cheap!\n" == captured.out
47+
48+
@pytest.mark.it("When input is 51 should print: Buy me some coffee you cheap ")
49+
def test_for_output_when_51(capsys, app):
50+
with mock.patch('builtins.input', lambda x: 51):
51+
app()
52+
captured = capsys.readouterr()
53+
assert "Buy me some coffee you cheap!\n" == captured.out
54+
4155
@pytest.mark.it("When input exactly 50 should print: You are a poor guy, go away")
42-
def test_for_less(capsys, app):
56+
def test_for_output_when_50(capsys, app):
4357
with mock.patch('builtins.input', lambda x: 50):
4458
app()
4559
captured = capsys.readouterr()
46-
assert "You are a poor guy, go away!\n" == captured.out
60+
assert "You are a poor guy, go away!\n" == captured.out
61+
62+
@pytest.mark.it("When input less than 50 should print: You are a poor guy, go away")
63+
def test_for_output_when_49(capsys, app):
64+
with mock.patch('builtins.input', lambda x: 49):
65+
app()
66+
captured = capsys.readouterr()
67+
assert "You are a poor guy, go away!\n" == captured.out
68+
69+
70+
71+

0 commit comments

Comments
 (0)