diff --git a/luhn.py b/luhn.py index 1136808..6d20498 100644 --- a/luhn.py +++ b/luhn.py @@ -16,7 +16,8 @@ def _digits(value: NumberLike) -> str: if not cleaned or not cleaned.isdigit(): raise ValueError( - "value must contain digits only, with optional spaces or hyphens" + "value must contain digits only, with optional spaces, hyphens, " + "dots, slashes, backslashes, or commas" ) return cleaned diff --git a/test_luhn.py b/test_luhn.py index 2b32579..add2f7b 100644 --- a/test_luhn.py +++ b/test_luhn.py @@ -30,7 +30,12 @@ def test_append_check_digit(self): self.assertEqual(append_check_digit("7992739871"), "79927398713") def test_rejects_non_digit_payloads(self): - with self.assertRaises(ValueError): + expected_message = ( + "value must contain digits only, with optional spaces, hyphens, " + "dots, slashes, backslashes, or commas" + ) + + with self.assertRaisesRegex(ValueError, expected_message): calculate_check_digit("123x") def test_rejects_unsupported_types(self):