Skip to content

Commit d9b55ce

Browse files
committed
updated exercise 02.1-Loop-from-the-top
1 parent 6667dc9 commit d9b55ce

File tree

1 file changed

+10
-16
lines changed
  • exercises/02.1-Loop-from-the-top

1 file changed

+10
-16
lines changed
Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
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 from the last")
11-
def test_output():
12-
captured = buffer.getvalue()
13-
assert "12\n25\n23\n55\n56432\n48\n23\n867543\n8\n654\n47889\n4\n5\n3423\n" in captured
5+
def test_output(capsys, app):
6+
app()
7+
captured = capsys.readouterr()
8+
assert "12\n25\n23\n55\n56432\n48\n23\n867543\n8\n654\n47889\n4\n5\n3423\n" in captured.out
149

15-
@pytest.mark.it("Be sure that use the for loop")
16-
def test_use_for():
17-
captures = buffer.getvalue()
10+
@pytest.mark.it("Be sure that you use the for loop in the exercises")
11+
def test_use_forLoop():
1812

19-
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
13+
f = open(path)
2014
content = f.read()
21-
assert content.find("for ") > 0
15+
assert content.find("for") > 0

0 commit comments

Comments
 (0)