def test_generator_raises_exception_for_non_integer_args(self): with self.assertRaises(TypeError) as context: prime_number_generator('ten') self.assertEqual( "Argument must be an integer", context.exception.message, "Invalid input" )
def test_function_generates_right_numbers_btwn_1_100(self): """Confirms the prime values generated from 1 to 100""" result = prime_number_generator(100) self.assertTrue([ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 ])
def test_generator_returns_list(self): result = prime_number_generator(12) self.assertEqual(type(result), list, msg='Invalid output')
def test_generator_returns_correct_result(self): result = prime_number_generator(10) self.assertEqual([2, 3, 5, 7], result)
def test_generator_returns_empty_list_for_negative_values(self): result = prime_number_generator(-10) self.assertEqual(result, [], msg='Function should return empty list for negative arguments')
def test_generator_returns_list_of_integers(self): result = prime_number_generator(15) self.assertTrue(all(isinstance(n, int) for n in result), msg="Generator returns list with non-integer items")
def test_function_handles_zero_correctly(self): """Ensures that zero is handled correctly""" result = prime_number_generator(0) self.assertEqual([], result)
def test_function_generates_right_numbers_btwn_1_10(self): """Confirms the prime values generated from 1 to 10""" result = prime_number_generator(20) self.assertEqual([2, 3, 5, 7, 11, 13, 17, 19], result)
def test_check_that_2_is_not_forgotten(self): """Ensures that two is handled correctly""" result = prime_number_generator(2) self.assertIn(2, result, msg="Please check how your function handles number 2")