File tree Expand file tree Collapse file tree 1 file changed +10
-16
lines changed
exercises/02.1-Loop-from-the-top Expand file tree Collapse file tree 1 file changed +10
-16
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 from the last" )
11
- def test_output ():
12
- captured = buffer .getvalue ()
13
- assert "12\n 25\n 23\n 55\n 56432\n 48\n 23\n 867543\n 8\n 654\n 47889\n 4\n 5\n 3423\n " in captured
5
+ def test_output (capsys , app ):
6
+ app ()
7
+ captured = capsys .readouterr ()
8
+ assert "12\n 25\n 23\n 55\n 56432\n 48\n 23\n 867543\n 8\n 654\n 47889\n 4\n 5\n 3423\n " in captured .out
14
9
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 ():
18
12
19
- f = open (os . path . dirname ( os . path . abspath ( __file__ )) + '/app.py' )
13
+ f = open (path )
20
14
content = f .read ()
21
- assert content .find ("for " ) > 0
15
+ assert content .find ("for" ) > 0
You can’t perform that action at this time.
0 commit comments