Random Number Tests
Example 1 - Student Function
Grading Tests:
import unittest
import random
class CodingRoomsUnitTests(unittest.TestCase):
def test_case1(self):
import example
random.seed(10)
self.assertListEqual([93, 24, 74, 81, 93, 21, 46, 79, 82, 55], example.make_random_numbers())
def test_case2(self):
import example
random.seed(55)
self.assertListEqual([31, 45, 39, 58, 30, 43, 58, 31, 65, 80], example.make_random_numbers() )
def test_case3(self):
import example
random.seed(2)
self.assertListEqual([27, 31, 30, 66, 41, 59, 52, 97, 47, 97], example.make_random_numbers())
if __name__ == '__main__':
unittest.main()Sample Solution:
Example 2 - Random Seed for random.randint()
Example 3 - Random Seed for random.choice()
Last updated
Was this helpful?