From d19de1102b6740b0e4a16744b7245508ceb48aa5 Mon Sep 17 00:00:00 2001 From: likechrisss Date: Sat, 28 Dec 2024 22:53:35 -0500 Subject: [PATCH] Added solution to the Spongecase challenge --- ...{spongecase_challenge.py => spongecase.py} | 13 ++++ solutions/tests/README.md | 59 ------------------- ...gecase_challenge.py => test_spongecase.py} | 19 ++++-- 3 files changed, 26 insertions(+), 65 deletions(-) rename solutions/{spongecase_challenge.py => spongecase.py} (77%) delete mode 100644 solutions/tests/README.md rename solutions/tests/{test_spongecase_challenge.py => test_spongecase.py} (78%) diff --git a/solutions/spongecase_challenge.py b/solutions/spongecase.py similarity index 77% rename from solutions/spongecase_challenge.py rename to solutions/spongecase.py index 47e0c25ff..537ebb3e1 100644 --- a/solutions/spongecase_challenge.py +++ b/solutions/spongecase.py @@ -1,3 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +A module for converting strings into SpongeCase (alternating lower and upper case). + +Module contents: +- spongecase: Converts a string into SpongeCase + +Created on 28/12/2024 +Author: Chrismy Leprince Paul Augustin +""" + + def spongecase(text: str) -> str: """ Convert a given string into SpongeCase, where letters alternate diff --git a/solutions/tests/README.md b/solutions/tests/README.md deleted file mode 100644 index b6eefe12e..000000000 --- a/solutions/tests/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Tests - -This directory contains the unit tests for the project. -The tests are written using the `unittest` framework. - -## Running Tests - -To run the tests, use the following command: - -```sh -python -m unittest -``` - -This command will automatically discover and run all the test cases in this directory. - -## Directory Structure - -The tests are organized as follows: - -```md -solutions/ - tests/ - __init__.py - test_example.py -``` - -- `__init__.py`: This file makes the directory a Python package. -- `test_example.py`: This file contains example test cases. - -## Writing Tests - -To add new tests, create a new file in the `tests` directory -and define your test cases using the `unittest` framework. - -Here is an example of a simple test case: - -```python -import unittest - -class TestExample(unittest.TestCase): - def test_addition(self): - self.assertEqual(1 + 1, 2) - -``` - -## Test Coverage - -Ensure that your tests cover all the critical parts of your codebase. -Aim for high test coverage to catch potential issues early. - -## Contributing - -If you would like to contribute to the tests, please follow these guidelines: - -1. Write clear and concise test cases. -2. Ensure that your tests pass before submitting a pull request. -3. Follow the existing code style and conventions. - -Let's maintain a high-quality codebase! 👩‍💻✨🚀 diff --git a/solutions/tests/test_spongecase_challenge.py b/solutions/tests/test_spongecase.py similarity index 78% rename from solutions/tests/test_spongecase_challenge.py rename to solutions/tests/test_spongecase.py index a0f019117..8039f673a 100644 --- a/solutions/tests/test_spongecase_challenge.py +++ b/solutions/tests/test_spongecase.py @@ -1,12 +1,19 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- """ -This module contains unit tests for the `spongecase` function. -The tests validate various scenarios, such as: -- Basic strings with spaces -- Single words -- Empty strings +Test module for spongecase function. + +Test categories: + - Basic cases: typical strings, single words + - Edge cases: empty string, all uppercase, all lowercase + - Special characters: punctuation, digits, symbols + +Created on 2024-12-28 +Author: Chrismy Leprince Paul Augustin """ import unittest -from solutions.spongecase_challenge import spongecase + +from solutions.spongecase import spongecase class TestSpongeCase(unittest.TestCase): """Unit tests for the spongecase function."""