Skip to content

Commit 5e41d90

Browse files
authored
Refactor test cases for add_numbers.py
Refactor tests to use expect_line for output validation and skip tests until previous ones pass.
1 parent 8e21163 commit 5e41d90

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
def test_prints_the_sum(run_script):
2-
stdout, _ = run_script("add_numbers_solution.py")
3-
lines = stdout.strip().splitlines()
4-
assert lines[0] == "11"
1+
import pytest
52

63

7-
def test_prints_the_difference(run_script):
8-
stdout, _ = run_script("add_numbers_solution.py")
9-
lines = stdout.strip().splitlines()
10-
assert lines[1] == "5"
4+
def test_prints_the_sum(run_script, expect_line):
5+
stdout, _ = run_script("add_numbers.py")
6+
expect_line(stdout, 1, "11")
117

128

13-
def test_prints_the_product(run_script):
14-
stdout, _ = run_script("add_numbers_solution.py")
15-
lines = stdout.strip().splitlines()
16-
assert lines[2] == "24"
9+
@pytest.mark.skip(reason="unlock once the test above passes")
10+
def test_prints_the_difference(run_script, expect_line):
11+
stdout, _ = run_script("add_numbers.py")
12+
expect_line(stdout, 2, "5")
13+
14+
15+
@pytest.mark.skip(reason="unlock once the test above passes")
16+
def test_prints_the_product(run_script, expect_line):
17+
stdout, _ = run_script("add_numbers.py")
18+
expect_line(stdout, 3, "24")

0 commit comments

Comments
 (0)