Skip to content

Commit 8e21163

Browse files
authored
Update test functions to use expect_line assertion
Refactor tests to use expect_line for output checks.
1 parent 96559ba commit 8e21163

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import pytest
22

33

4-
def test_prints_the_sum(run_script):
4+
def test_prints_the_sum(run_script, expect_line):
55
stdout, _ = run_script("add_numbers.py")
6-
lines = stdout.strip().splitlines()
7-
assert lines[0] == "11"
6+
expect_line(stdout, 1, "11")
87

98

109
@pytest.mark.skip(reason="unlock once the test above passes")
11-
def test_prints_the_difference(run_script):
10+
def test_prints_the_difference(run_script, expect_line):
1211
stdout, _ = run_script("add_numbers.py")
13-
lines = stdout.strip().splitlines()
14-
assert lines[1] == "5"
12+
expect_line(stdout, 2, "5")
1513

1614

1715
@pytest.mark.skip(reason="unlock once the test above passes")
18-
def test_prints_the_product(run_script):
16+
def test_prints_the_product(run_script, expect_line):
1917
stdout, _ = run_script("add_numbers.py")
20-
lines = stdout.strip().splitlines()
21-
assert lines[2] == "24"
18+
expect_line(stdout, 3, "24")

0 commit comments

Comments
 (0)