Skip to content

Commit

Permalink
Create test_check_palindromes.py
Browse files Browse the repository at this point in the history
  • Loading branch information
fevziismailsahin committed Jan 11, 2025
1 parent f98fdb2 commit c251df7
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions solutions/tests/test_check_palindromes.py
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()

0 comments on commit c251df7

Please sign in to comment.