From 765f6a5b4eea93aa4a530a9b469df999acce7a60 Mon Sep 17 00:00:00 2001 From: NimahMasuud Date: Sun, 12 Jan 2025 13:36:37 +0100 Subject: [PATCH] Initial commit with to_uppercase function and tests --- solutions/tests/test_to_uppercase.py | 4 ++-- solutions/to_uppercase.py | 35 +++++++++++++++------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/solutions/tests/test_to_uppercase.py b/solutions/tests/test_to_uppercase.py index 9723cdbd8..0ec0f06d5 100644 --- a/solutions/tests/test_to_uppercase.py +++ b/solutions/tests/test_to_uppercase.py @@ -3,8 +3,8 @@ """ Unit tests for the to_uppercase function. -Created on XX XX XX -@author: Your Name +Created on 11 01 2025 +@author: Nimah Masuud """ import unittest diff --git a/solutions/to_uppercase.py b/solutions/to_uppercase.py index 3662d167c..3992423b8 100644 --- a/solutions/to_uppercase.py +++ b/solutions/to_uppercase.py @@ -2,36 +2,39 @@ # -*- coding: utf-8 -*- """ Module for converting strings to uppercase. - Module contents: - to_uppercase: Converts a given string to uppercase. - -Created on XX XX XX -@author: Your Name +Created on 09 Jan 2025 +@author: Nimah """ def to_uppercase(s: str) -> str: """Converts a string to uppercase. - Parameters: s (str): The string to be converted. - Returns: str: The string with all characters in uppercase. - Raises: TypeError: If the input is not a string. - - >>> to_uppercase("hello") - 'HELLO' - - >>> to_uppercase("Python") - 'PYTHON' - - >>> to_uppercase("123abc") - '123ABC' + Examples: + >>> to_uppercase("hello") + 'HELLO' + >>> to_uppercase("Python") + 'PYTHON' + >>> to_uppercase("123abc") + '123ABC' + >>> to_uppercase("") + '' + >>> to_uppercase("!@#$%^") + '!@#$%^' """ if not isinstance(s, str): raise TypeError("Input must be a string.") return s.upper() + + +if __name__ == "__main__": + import doctest + + doctest.testmod()