5
5
def test_love ():
6
6
f = open (os .path .dirname (os .path .abspath (__file__ ))+ '/app.py' )
7
7
content = f .read ()
8
- value = False
9
- if (content .find ("spanish_translations['love'] = 'amor'" ) > 0 or content .find ('spanish_translations["love"] = "amor"' ) > 0 ):
10
- value = True
11
- assert value == True
8
+ regex = re .compile (r"spanish_translations\[\s*[\'\"]\s*love\s*[\'\"]\s*\]\s*\=\s*[\'\"]\s*amor\s*[\'\"]" )
9
+ assert bool (regex .search (content )) == True
12
10
13
11
@pytest .mark .it ("You should add `code` programatically to the dictionary" )
14
12
def test_code ():
15
13
f = open (os .path .dirname (os .path .abspath (__file__ ))+ '/app.py' )
16
14
content = f .read ()
17
- value = False
18
- if (content .find ("spanish_translations['code'] = 'codigo'" ) > 0 or content .find ('spanish_translations["code"] = "codigo"' ) > 0 ):
19
- value = True
20
- assert value == True
15
+ regex = re .compile (r"spanish_translations\[\s*[\'\"]\s*code\s*[\'\"]\s*\]\s*\=\s*[\'\"]\s*codigo\s*[\'\"]" )
16
+ assert bool (regex .search (content )) == True
21
17
22
18
@pytest .mark .it ("You should add `smart` programatically to the dictionary" )
23
19
def test_smart ():
24
20
f = open (os .path .dirname (os .path .abspath (__file__ ))+ '/app.py' )
25
21
content = f .read ()
26
- value = False
27
- if (content .find ("spanish_translations['smart'] = 'inteligente'" ) > 0 or content .find ('spanish_translations["smart"] = "inteligente"' ) > 0 ):
28
- value = True
29
- assert value == True
22
+ regex = re .compile (r"spanish_translations\[\s*[\'\"]\s*smart\s*[\'\"]\s*\]\s*\=\s*[\'\"]\s*inteligente\s*[\'\"]" )
23
+ assert bool (regex .search (content )) == True
30
24
31
25
@pytest .mark .it ("You should print in the console the dictionary with proper translations" )
32
26
def test_multp (capsys , app ):
33
27
import app
34
28
captured = capsys .readouterr ()
35
- assert "All {'dog': 'perro', 'house': 'casa', 'cat': 'gato', 'love': 'amor', 'code': 'codigo', 'smart': 'inteligente'}" in captured .out
29
+ assert "{'dog': 'perro', 'house': 'casa', 'cat': 'gato', 'love': 'amor', 'code': 'codigo', 'smart': 'inteligente'}" in captured .out
0 commit comments