From 7932f5e4a68a5e89f0f64e055e30fec563bf6ff8 Mon Sep 17 00:00:00 2001 From: Milad Khoshdel Date: Sat, 12 Sep 2026 21:35:06 +0330 Subject: [PATCH 1/2] fix: clarify invalid input error message --- luhn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 88b3996a007c76317c52f84bc2afc7c7be4d2340 Mon Sep 17 00:00:00 2001 From: Milad Khoshdel Date: Sat, 12 Sep 2026 21:35:12 +0330 Subject: [PATCH 2/2] test: clarify invalid input error message --- test_luhn.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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):