{"id":22440065,"url":"https://github.com/niewiaro/mentoring-2024","last_synced_at":"2025-07-17T14:04:50.680Z","repository":{"id":263751997,"uuid":"891357300","full_name":"Niewiaro/mentoring-2024","owner":"Niewiaro","description":"String Calculator with unittest and doctest","archived":false,"fork":false,"pushed_at":"2024-12-06T21:41:42.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T09:31:13.295Z","etag":null,"topics":["doctest","python","unittest"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Niewiaro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-20T07:31:14.000Z","updated_at":"2024-12-06T21:42:35.000Z","dependencies_parsed_at":"2024-11-20T09:25:19.929Z","dependency_job_id":null,"html_url":"https://github.com/Niewiaro/mentoring-2024","commit_stats":null,"previous_names":["niewiaro/mentoring-2024"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Niewiaro/mentoring-2024","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Niewiaro%2Fmentoring-2024","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Niewiaro%2Fmentoring-2024/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Niewiaro%2Fmentoring-2024/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Niewiaro%2Fmentoring-2024/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Niewiaro","download_url":"https://codeload.github.com/Niewiaro/mentoring-2024/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Niewiaro%2Fmentoring-2024/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265614136,"owners_count":23798390,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["doctest","python","unittest"],"created_at":"2024-12-06T01:16:51.594Z","updated_at":"2025-07-17T14:04:50.665Z","avatar_url":"https://github.com/Niewiaro.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# String Calculator with `unittest` and `doctest`\n\nWelcome to the **String Calculator** project! This repository showcases my journey in exploring Python's testing frameworks: `unittest` and `doctest`. The implementation follows the [String Calculator Kata](https://codingdojo.org/kata/StringCalculator/) with additional features.\n\n## Features\n\n- **Addition of Numbers**: Supports integers and floats, separated by commas or newlines.\n- **Custom Error Handling**: Validates input format and raises descriptive exceptions.\n- **Extensive Testing**:\n  - `doctest`: Inline examples to ensure correctness during development.\n  - `unittest`: Comprehensive test cases for edge scenarios.\n\n---\n\n## File Structure\n\n### `main.py`\n\nThis file implements the core functionality:\n\n- `add(number: str, re_separator: str = \",|\\n\") -\u003e str`  \n  Adds numbers from a delimited string.  \n  Example usage (validated via `doctest`):\n  ```python\n  \u003e\u003e\u003e add(\"1,2\")\n  '3'\n  \u003e\u003e\u003e add(\"1.5,2.5\")\n  '4.0'\n  ```\n\n- Error handling:\n  - Empty string → Returns `'0'`.\n  - Trailing separator → Raises `ValueError`.\n  - Non-string input → Raises `TypeError`.\n\n- Benchmarking utility with `timeit`.\n\n### `test_main.py`\n\nContains test cases written using `unittest`:\n\n- Validates core functionalities.\n- Tests edge cases:\n  - Mixed separators.\n  - Trailing or missing separators.\n  - Negative numbers.\n  - Large numbers.\n  - Incorrect input types.\n\n---\n\n## How to Run\n\n### Running `doctest`\n\nTo validate inline examples using `doctest`:\n```bash\npython main.py\n```\n\n### Running `unittest`\n\nTo execute unit tests:\n```bash\npython -m unittest test_main.py\n```\n\n---\n\n## Example Use Case\n\n```python\nfrom main import add\n\n# Add numbers from a string\nresult = add(\"10,20,30\")\nprint(result)  # Output: '60'\n\n# Handle floats\nresult = add(\"1.1,2.2,3.3\")\nprint(result)  # Output: '6.6'\n```\n\n---\n\n## Project Goals\n\n1. **Learn `doctest`**: Write self-validating examples within the function docstrings.\n2. **Explore `unittest`**: Build robust test suites for various scenarios.\n3. **Practice Error Handling**: Create descriptive and user-friendly exceptions.\n\n---\n\n## Feedback \u0026 Contributions\n\nI welcome feedback and suggestions for improving the implementation or test coverage. Feel free to open an issue or a pull request!\n\n---\n\nThank you for visiting! 🎉\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniewiaro%2Fmentoring-2024","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniewiaro%2Fmentoring-2024","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniewiaro%2Fmentoring-2024/lists"}