forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f98fdb2
commit c251df7
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
""" | ||
Module represents unit test for check_palindromes | ||
Created on 01/11/2025 | ||
Author fevziismailsahin | ||
""" | ||
|
||
import unittest | ||
|
||
from solutions.check_palindromes import check_palindromes | ||
|
||
|
||
class TestPalindromeChecker(unittest.TestCase): | ||
def test_palindrome_words(self): | ||
""" | ||
Test: Check palindrome words correctly identified. | ||
""" | ||
with self.assertLogs(level="INFO") as log: | ||
check_palindromes(["Radar", "12321", "aA"]) | ||
self.assertIn("'Radar' is a palindrome.", log.output) | ||
self.assertIn("'12321' is a palindrome.", log.output) | ||
self.assertIn("'aA' is a palindrome.", log.output) | ||
|
||
def test_non_palindrome_words(self): | ||
""" | ||
Test: Check non-palindrome words correctly identified. | ||
""" | ||
with self.assertLogs(level="INFO") as log: | ||
check_palindromes(["Hello", "12345", "Test"]) | ||
self.assertIn("'Hello' is not a palindrome.", log.output) | ||
self.assertIn("'12345' is not a palindrome.", log.output) | ||
self.assertIn("'Test' is not a palindrome.", log.output) | ||
|
||
def test_mixed_case(self): | ||
""" | ||
Test: Check case-insensitive palindrome detection. | ||
""" | ||
with self.assertLogs(level="INFO") as log: | ||
check_palindromes(["aA"]) | ||
self.assertIn("'aA' is a palindrome.", log.output) | ||
|
||
def test_special_characters(self): | ||
""" | ||
Test: Check if special characters are correctly removed and palindrome check works. | ||
""" | ||
with self.assertLogs(level="INFO") as log: | ||
check_palindromes(["1.232.1"]) | ||
self.assertIn("'1.232.1' is a palindrome.", log.output) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |