-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capital letters #32
Capital letters #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The challenge is tackled effectively, with a well-implemented solution and comprehensive testing to ensure functionality across a variety of scenarios, including standard, edge, and defensive cases. Excellent work on maintaining clarity, input validation, and robust test coverage, demonstrating a thorough understanding of the task—well done!
solutions/convert_to_capital.py
Outdated
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
A module that converts letters to upper case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just correct that uppercase is a one word
solutions/convert_to_capital.py
Outdated
"""Asks the user to enter a text and returns the text in capital | ||
|
||
parameters: | ||
user_text = in str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could be corrected to this format
user_text (type): description
like
user_text (str): The user input text to be converted to uppercase.
solutions/convert_to_capital.py
Outdated
parameters: | ||
user_text = in str | ||
returns: | ||
user_text in capital letters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could add the return type here to be like this
(str) : user_text in capital letters
solutions/convert_to_capital.py
Outdated
user_text in capital letters | ||
|
||
raises: | ||
AssertionError: if input is empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add as you mentioned in the assrtionError message to be like this
AssertionError: If the input is empty or contains only spaces.
solutions/convert_to_capital.py
Outdated
raises: | ||
AssertionError: if input is empty | ||
|
||
examples: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you rewrite Examples with capital E
also the previous lines , to start with capital letter (Raises , Returns and Parameters)
|
||
""" | ||
A module to test convert_to_capital function | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add here the Test categories with Standard cases, Edge cases, and Defensive tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
""" | ||
|
||
|
||
def convert_to_capital(user_text: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Current: convert_to_capital
Improvement: While this name is clear, it could be more explicit in describing what the function does, such as convert_to_uppercase, to clearly convey that it deals with uppercase conversion. "Capital" can be ambiguous because people might think it deals with capitalization rules (e.g., first letter capitalized), not case swapping.
Suggested Improvement: convert_to_uppercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Created on 31 12 2024 | ||
|
||
@author: Kareiman Altayeb | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvement: The module docstring does not specify the function’s behavior as clearly as it could. Consider improving the explanation of the function and its purpose.
"""
This function takes a user input string and returns the string with all characters in uppercase.
It handles edge cases where the input is empty or contains only spaces.
"""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added more description but explaining the edge behavior is mentioned within the tests
|
||
if not user_text: | ||
raise AssertionError("Entry cannot be empty or just spaces") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvement: The use of strip() and then checking if not user_text is good. However, you can directly handle empty strings in the assertion, which makes the function simpler:
Action: Use strip() to handle spaces at the beginning or end of the input more cleanly in the assertion check.
e.g
if not user_text.strip():
raise AssertionError("Entry cannot be empty or just spaces")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already call strip() when checking for empty strings, so there’s no need to call it again on user_text, it is redundant.
|
||
@author: Kareiman Altayeb | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file’s docstring is minimal and could be expanded to better describe the purpose of the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of the edge, classical cases and defensive tests is explained below
|
||
|
||
class TestConvertCapitalLetters(unittest.TestCase): | ||
"Tests convert_to_capital function" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvement: The test class name TestConvertCapitalLetters is clear, but it could be improved to use a more conventional PascalCase naming style.
Action: Use PascalCase for the test class name, e.g., TestConvertToCapital.
class TestConvertToCapital(unittest.TestCase):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work kariman ..
name: solution review
about: A template PR for code review with a checklist
Behavior
Files
/tests/test_file_name.py
Unit Tests
Function Docstring
Raises:
The Function
Strategy
Do's
Don'ts
Implementation
when it's too restricting.
print
statements anywhere