def test_invalid_nhs_number_detection(self):
     """Check that invalid nhs numbers will be rejected"""
     with self.assertRaisesRegex(ValueError, "Number is invalid"):
         calculate_check_digit("123456789")
 def test_too_long_nhs_numbers_raise_exception(self):
     """Check that if the number is too long, an error is raised"""
     with self.assertRaisesRegex(ValueError, "Expecting nine digits"):
         calculate_check_digit("1234567890")
 def test_providing_something_not_a_number_raises_exception(self):
     """Check that if the string is not numeric, an error is raised"""
     with self.assertRaisesRegex(ValueError,
                                 "nhs_number must comprise only digits"):
         calculate_check_digit("A")
 def test_check_digits_calculate(self):
     """Check that the check digit is correct"""
     for number in VALID_NHS_NUMBERS:
         self.assertEqual(calculate_check_digit(number[:-1]),
                          int(number[9]))