From 01b758db6e5d3e8fe472c48458b9b489a755024a Mon Sep 17 00:00:00 2001 From: Noorelsalam Date: Mon, 30 Dec 2024 14:37:26 +0100 Subject: [PATCH] Included assertion and passing its test --- solutions/convert_string_to_uppercase.py | 2 ++ solutions/tests/test_convert_string_to_uppercase.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/solutions/convert_string_to_uppercase.py b/solutions/convert_string_to_uppercase.py index 218dd9554..1aa3cb5f9 100644 --- a/solutions/convert_string_to_uppercase.py +++ b/solutions/convert_string_to_uppercase.py @@ -26,6 +26,8 @@ def convert_string_to_uppercase(text: str) -> str: >>> sum_of_digits("") '' """ + assert isinstance(text, str), "The input text must be a string." + upper_string = text.upper() return upper_string diff --git a/solutions/tests/test_convert_string_to_uppercase.py b/solutions/tests/test_convert_string_to_uppercase.py index 949995b29..10673a253 100644 --- a/solutions/tests/test_convert_string_to_uppercase.py +++ b/solutions/tests/test_convert_string_to_uppercase.py @@ -75,3 +75,8 @@ def test_string_with_newline(self): def test_string_with_only_whitespace(self): """Test the convert_string_to_uppercase function with a string with only whitespace""" self.assertEqual(convert_string_to_uppercase(" "), " ") + + def test_non_string_input(self): + """Test the convert_string_to_uppercase function with a non-string input""" + with self.assertRaises(AssertionError): + convert_string_to_uppercase(123)