Example #1
0
 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"
         )
Example #2
0
 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
     ])
Example #3
0
 def test_generator_returns_list(self):
     result = prime_number_generator(12)
     self.assertEqual(type(result), list, msg='Invalid output')
Example #4
0
 def test_generator_returns_correct_result(self):
     result = prime_number_generator(10)
     self.assertEqual([2, 3, 5, 7], result)
Example #5
0
 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')
Example #6
0
 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")
Example #7
0
 def test_function_handles_zero_correctly(self):
     """Ensures that zero is handled correctly"""
     result = prime_number_generator(0)
     self.assertEqual([], result)
Example #8
0
 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)
Example #9
0
 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")