Skip to content

Commit 6d50be0

Browse files
Solution.hide.py and test modified on ex 09
1 parent 9848e31 commit 6d50be0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

exercises/09-Random-Numbers/solution.hide.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
def get_randomInt():
44
# CHANGE ONLY THIS LINE BELOW
5-
random_number = random.randrange(1,10)
5+
random_number = random.randint(1,10)
66
return random_number
77

88

exercises/09-Random-Numbers/test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_only_change_line_5():
1414
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
1515
with open(path, 'r') as content_file:
1616
content = content_file.read()
17-
line = r"print(\s*)\(get_randomInt(\s*)\((\s*)\)(\s*)\)"
17+
line = r"print\s*\(\s*get_randomInt\s*\(\s*\)\s*\)"
1818
regex = re.compile(line)
1919
assert bool(regex.search(content)) == True
2020

@@ -26,18 +26,18 @@ def test_function_exists():
2626
raise AttributeError('The function "get_randomInt" should return only values from 1 through 10 inclusive')
2727

2828
@pytest.mark.it("get_randomInt function should return a random integer between 1 and 10")
29-
def test_function_exists():
29+
def test_function_exists1():
3030
try:
31-
for i in range(100):
32-
if app.get_randomInt() < 1 or app.get_randomInt() > 10:
33-
# only asserting if value is outside the range, else it will pass
34-
assert app.get_randomInt() < 1 or app.get_randomInt() > 10
31+
for i in range(10):
32+
# only asserting if value is outside the range, else it will pass
33+
result = app.get_randomInt()
34+
assert result > 1 and result < 10
3535
except AttributeError:
3636
raise AttributeError('The function "get_randomInt" is returning values outside the specified range')
3737

3838
@pytest.mark.it("get_randomInt function should NOT be returning a static integer value")
3939
# in case user returns single value between [1 and 10]
40-
def test_function_exists():
40+
def test_function_exists2():
4141
try:
4242
tries = 0
4343
output = app.get_randomInt()

0 commit comments

Comments
 (0)