Skip to content

Commit 6667dc9

Browse files
committed
updated exercise 02-loop-list
1 parent 9acc9d3 commit 6667dc9

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

exercises/02-Loop-list/test.py

Lines changed: 7 additions & 13 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-
6-
7-
import pytest
8-
import app
9-
import os
1+
import io, sys, pytest, os, re
2+
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
103

114
@pytest.mark.it("Print the all items from the list")
12-
def test_output():
13-
captured = buffer.getvalue()
14-
assert "232\n32\n1\n4\n55\n4\n3\n32\n3\n24\n5\n5\n5\n34\n2\n35\n5365743\n52\n34\n3\n55\n" in captured
5+
def test_output(capsys, app):
6+
app()
7+
captured = capsys.readouterr()
8+
assert "232\n32\n1\n4\n55\n4\n3\n32\n3\n24\n5\n5\n5\n34\n2\n35\n5365743\n52\n34\n3\n55\n" in captured.out
159

1610
@pytest.mark.it("Be sure that you use the for loop in the exercises")
1711
def test_use_forLoop():
1812

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

0 commit comments

Comments
 (0)