File tree Expand file tree Collapse file tree 1 file changed +9
-15
lines changed
exercises/02.2-Loop-adding-two Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change 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'
9
3
10
4
@pytest .mark .it ("Loop two by two" )
11
- def test_output ():
12
- captured = buffer .getvalue ()
13
- assert "3423\n 4\n 654\n 867543\n 48\n 55\n 25\n " in captured
5
+ def test_output (capsys , app ):
6
+ app ()
7
+ captured = capsys .readouterr ()
8
+ assert "3423\n 4\n 654\n 867543\n 48\n 55\n 25\n " in captured .out
14
9
15
10
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 ():
19
13
20
- f = open (os . path . dirname ( os . path . abspath ( __file__ )) + '/app.py' )
14
+ f = open (path )
21
15
content = f .read ()
22
16
assert content .find ("for" ) > 0
23
17
You can’t perform that action at this time.
0 commit comments