Skip to content

Commit 5a1c67a

Browse files
committed
Added a test to check if numberguessing is working correctly or not
1 parent abdef98 commit 5a1c67a

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import random
2+
3+
def guessing_game():
4+
"""
5+
This function should guess a number between 0 and 100
6+
"""
7+
return random.randint(0, 100)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import unittest
2+
from number_guessing import guessing_game
3+
4+
class NumberGuessingTestClass(unittest.TestCase):
5+
"""
6+
This class will be used to test the number guessing game method
7+
"""
8+
9+
def test_expect_result_to_be_in_valid_range(self):
10+
"""
11+
Here lets test the number_guessing and ensure values are
12+
in the range of 0 to 100
13+
"""
14+
result_1 = guessing_game()
15+
self.assertTrue(
16+
0 < result_1 <= 100,
17+
msg="""Number guessing game should
18+
predict values in range of 0 to 100""")
19+
20+
if __name__ == '__main__':
21+
unittest.main(verbosity=2)

0 commit comments

Comments
 (0)