77import os
88import re
99
10- @pytest .mark .it ("You should update only line 5 using randint()" )
10+ @pytest .mark .it ("You should edit the function randint() to generate a random number between 1 and 10 " )
1111def test_conditional ():
1212 path = os .path .dirname (os .path .abspath (__file__ ))+ '/app.py'
1313 with open (path , 'r' ) as content_file :
1414 content = content_file .read ()
15- pattern = r"random_number(\s*)=(\s*)random\.rand\w+\(1,10 \)"
15+ pattern = r"random_number(\s*)=(\s*)random\.rand\w+(\s)*\((\s)*1(\s)*,(\s)*10(\s)* \)"
1616 regex = re .compile (pattern )
1717 assert bool (regex .search (content )) == True
1818
19+ @pytest .mark .it ("You should only change line 5" )
20+ def test_only_change_line_5 ():
21+ path = os .path .dirname (os .path .abspath (__file__ ))+ '/app.py'
22+ with open (path , 'r' ) as content_file :
23+ content = content_file .read ()
24+ line_1 = r"import(\s)random"
25+ line_2 = r"def(\s)get_randomInt\((\s*)\)(\s*)\:"
26+ line_3 = r"return(\s)random_number"
27+ line_4 = r"print(\s*)\(get_randomInt(\s*)\((\s*)\)(\s*)\)"
28+
29+ regex = re .compile (line_1 )
30+ regex = re .compile (line_2 )
31+ regex = re .compile (line_3 )
32+ regex = re .compile (line_4 )
33+
34+ assert bool (regex .search (content )) == True
35+ assert bool (regex .search (content )) == True
36+ assert bool (regex .search (content )) == True
37+ assert bool (regex .search (content )) == True
0 commit comments