Skip to content

Commit 7fe4eec

Browse files
committed
update exercise 02.2-Loop-adding-two
1 parent d9b55ce commit 7fe4eec

File tree

1 file changed

+9
-15
lines changed
  • exercises/02.2-Loop-adding-two

1 file changed

+9
-15
lines changed
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
import io
2-
import sys
3-
sys.stdout = buffer = io.StringIO()
4-
5-
from app import my_sample_list
6-
import pytest
7-
import app
8-
import os
1+
import io, sys, pytest, os
2+
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
93

104
@pytest.mark.it("Loop two by two")
11-
def test_output():
12-
captured = buffer.getvalue()
13-
assert "3423\n4\n654\n867543\n48\n55\n25\n" in captured
5+
def test_output(capsys, app):
6+
app()
7+
captured = capsys.readouterr()
8+
assert "3423\n4\n654\n867543\n48\n55\n25\n" in captured.out
149

1510

16-
@pytest.mark.it("The for loop was used")
17-
def test_use_for():
18-
captured = buffer.getvalue()
11+
@pytest.mark.it("Be sure that you use the for loop in the exercises")
12+
def test_use_forLoop():
1913

20-
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
14+
f = open(path)
2115
content = f.read()
2216
assert content.find("for") > 0
2317

0 commit comments

Comments
 (0)