Skip to content

Commit da6762c

Browse files
Issue #292 fixed
1 parent c01dee3 commit da6762c

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
age = int(input('What is your age?\n'))
2+
# CHANGE THE CODE BELOW TO ADD 10 TO AGE
3+
print("Your age is: "+str(age))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import random
2+
3+
def get_randomInt():
4+
# CHANGE ONLY THIS LINE BELOW
5+
random_number = random.random()
6+
return random_number
7+
8+
9+
10+
print(get_randomInt())
Binary file not shown.

exercises/09-Random-Numbers/test.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,31 @@
77
import os
88
import 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")
1111
def 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

Comments
 (0)