1
1
import io
2
2
import sys
3
3
sys .stdout = buffer = io .StringIO ()
4
-
5
4
# from app import my_function
6
5
import pytest
7
6
import os
8
7
import app
9
8
import re
9
+ path = os .path .dirname (os .path .abspath (__file__ ))+ '/app.py'
10
10
11
11
@pytest .mark .it ('You should create a variable named variables_are_cool' )
12
12
def test_variable_exists ():
@@ -17,15 +17,16 @@ def test_variable_exists():
17
17
18
18
@pytest .mark .it ('Variables_are_cool value should be like 2345 * 7323 ' )
19
19
def test_use_variable_name ():
20
- path = os .path .dirname (os .path .abspath (__file__ ))+ '/app.py'
21
- with open (path , 'r' ) as content_file :
22
- content = content_file .read ()
23
- regex = re .compile (r"variables_are_cool(\s*)=(\s*)2345(\s*)\*(\s*)7323" )
24
- assert bool (regex .search (content )) == True
20
+ result = app .variables_are_cool == 17172435
21
+ assert result == True
22
+ # with open(path, 'r') as content_file:
23
+ # content = content_file.read()
24
+ # regex = re.compile(r"variables_are_cool(\s*)=(\s*)2345(\s*)\*(\s*)7323")
25
+ # assert bool(regex.search(content)) == True
25
26
26
27
@pytest .mark .it ('Print on the console the variables_are_cool value ' )
27
28
def test_for_file_output (capsys ):
28
-
29
- from app import variables_are_cool
29
+ # from app import variables_are_cool
30
30
captured = buffer .getvalue ()
31
- assert captured == str (variables_are_cool )+ '\n '
31
+ # assert captured == str(variables_are_cool)+'\n' # 17172435 -> output
32
+ assert captured == '17172435\n '
0 commit comments