Skip to content

Commit

Permalink
Included assertion and passing its test
Browse files Browse the repository at this point in the history
  • Loading branch information
NoorelsalamAlmakki committed Dec 30, 2024
1 parent a27873b commit 01b758d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions solutions/convert_string_to_uppercase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions solutions/tests/test_convert_string_to_uppercase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 01b758d

Please sign in to comment.