File tree Expand file tree Collapse file tree
Dec21/UnitTesting/workouts/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments