{"id":27158071,"url":"https://github.com/lindelwa122/colorful-test","last_synced_at":"2025-04-08T21:54:49.503Z","repository":{"id":266058587,"uuid":"897113240","full_name":"lindelwa122/Colorful-Test","owner":"lindelwa122","description":"A unit testing framework with colorful messages.","archived":false,"fork":false,"pushed_at":"2025-02-07T15:28:35.000Z","size":821,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T21:17:05.028Z","etag":null,"topics":["colorful","cool","framework","python","testing","unittesting"],"latest_commit_sha":null,"homepage":"https://colorful-test.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lindelwa122.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-12-02T03:41:21.000Z","updated_at":"2025-03-04T12:57:17.000Z","dependencies_parsed_at":"2025-01-08T15:30:40.463Z","dependency_job_id":"db3c2ce1-2339-435b-954d-b117569d9195","html_url":"https://github.com/lindelwa122/Colorful-Test","commit_stats":null,"previous_names":["lindelwa122/colorful-test"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindelwa122%2FColorful-Test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindelwa122%2FColorful-Test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindelwa122%2FColorful-Test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindelwa122%2FColorful-Test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lindelwa122","download_url":"https://codeload.github.com/lindelwa122/Colorful-Test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247934789,"owners_count":21020725,"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":["colorful","cool","framework","python","testing","unittesting"],"created_at":"2025-04-08T21:54:49.091Z","updated_at":"2025-04-08T21:54:49.494Z","avatar_url":"https://github.com/lindelwa122.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Colorful Test\n\n**Colorful Test** is a unit testing framework that is similar to and inspired by Python's [unittest](https://docs.python.org/3/library/unittest.html). What makes **Colorful Test** cool and different is that it's uniquely designed for educational settings while also supporting general-purpose use. It displays error messages in *a colorful and more helpful way*, and success messages in a way that makes students proud of their work. \n\nIt also guides students through their projects by *failing fast* *(by default)* and showing them exactly what went wrong. *unittest* doesn't give you much freedom when it comes to the order of test execution, but this is so important for student projects that, with **Colorful Test**, you can just append a number at the end of the test name to determine the order.\n\nWe also provide a *grade/score feature* *(optional)* that makes it easy to grade student projects. The run method returns a TestResults object that lets you customize how the output looks, giving you more control.\n\nIf you're familiar with *unittest*, it shouldn't be hard to get a grasp of how **Colorful Test** works, and you can skip to the official docs.\n\n## Installation\n\nTo use Colorful Test, first install it using pip:\n\n```console\n$ pip install colorful-test\n```\n\n## Documentation\n\nRead the full documentation [here](https://colorful-test.readthedocs.io/en/latest/).\n\n## Basic Example\n\nColorful Test provides a handful of useful tools to help you construct and run tests. Here's a basic example of some of those tools in action:\n\n```python\nfrom colorful_test import TestCase, show_message\nfrom solution import add, mul, div\n\nclass TestSolution(TestCase):\n\n    @show_message(\n        success='Your add method works as expected',\n        fail='''\n        Your add method doesn't work as expected. Hints:\n\n        Expected: %s\n        Received: %f\n        '''\n    )\n    def test_basic_addition_2(self):\n        self.assert_equal(add(1, 1), 2)\n        self.assert_equal(add(1, 2), 3)\n\n    @show_message(\n        success='Your mul method works as expected',\n        fail='''\n        Your mul method doesn't work as expected. Hints:\n\n        Expected: %s\n        Received: %f\n        '''\n    )\n    def test_basic_multiplication_0(self):\n        self.assert_equal(mul(1, 1), 1)\n        self.assert_equal(mul(1, 2), 2)\n\n    @show_message(\n        success='Your div method works as expected',\n        fail='Your div method should raise a ZeroDivisionError if the second argument is 0'\n    )\n    def test_basic_division_error_1(self):\n        self.assert_raises(ZeroDivisionError, div, 3, 0)\n\nif __name__ == '__main__':\n    TestSolution.run_and_output_results()\n```\n\nA TestCase is created by inheriting `TestCase`. The test runner looks for methods that start with **test_** and considers them as tests. These tests are then ordered based on the number appended to their names.\n\nIn each test, **assert_equal** or **assert_raises** can be used—these work similarly to [`assertEqual`](https://docs.python.org/3/library/unittest.html) and [`assertRaises`](https://docs.python.org/3/library/unittest.html) from the `unittest` framework.  \n\n- **assert_equal** checks if the first and second arguments are equivalent.  \n- **assert_raises** verifies whether the specified callable raises an error with the given arguments.  \n- Alternatively, you can simply use **assert**, and the test runner will still accumulate all test results and generate a test report.\n\nOne thing to note is that **test_basic_multiplication_0** will be executed first, followed by **test_basic_division_error_1**, and so on. This happens because of how the tests are ordered.  \n\nAppending a number to test method names is not mandatory—if omitted, test methods will be ordered alphabetically.\n\n## Tutorial\n\n[This tutorial](https://colorful-test.readthedocs.io/en/latest/tutorial.html) will guide you on how to write unit tests using **Colorful Test**.\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\". Don't forget to give the project a star! Thanks again!\n\n1. [Fork](https://github.com/lindelwa122/Colorful-Test/fork) this repository.\n\n2. Clone the repository to your own machine by running one of the following commands:\n\n   - HTTPS\n\n   ```\n   git clone https://github.com/\u003cyour-username\u003e/Colorful-Test.git\n   ```\n\n   OR\n\n   - SSH\n\n   ```\n   git clone git@github.com:\u003cyour-username\u003e/Colorful-Test.git\n   ```\n\n   OR\n\n   - Github CLI:\n\n   ```\n   gh repo clone \u003cyour-username\u003e/Colorful-Test\n   ```\n\n3. Create a new branch. The name of the branch must reflect the change you are about to make.\n\n   ```\n   git checkout -b \u003cbranch-name\u003e\n   ```\n\n4. Make your changes or add your new feature. Remember to commit early and commit often. Read our commit rules [here](/COMMIT_RULES.md).\n\n   - Short commit messages:\n     ```\n     git add \u003cchanged-files\u003e\n     git commit -m \"\u003ccommit-message\u003e\"\n     ```\n   - Long commit messages:\n     ```\n     git add \u003cchanged-files\u003e\n     git commit\n     ```\n\n5. Push your changes to Github by running this command:\n\n   ```\n   git push origin \u003cbranch-name\u003e\n   ```\n\n6. Go over to GitHub and create a pull request. Make sure to include a comment explaining the additions. Please include the issue number being addressed in your comment. For instance, if you were resolving issue 6, add `Issue: #6` at the end of your comment. For more information, please refer to our contributing rules [here](/CONTRIBUTING.md).\n\n## More ways to contribute\n\nYou can contribute not only by writing code but also by assisting us in enhancing this README, drafting documentation, creating tutorials, and more.\n\n- Fix spelling and grammatical errors across our documentation.\n- Enhance this README and other docs.\n- Create more tutorials on our website.\n- Produce video tutorials.\n- Write tests.\n- Design a logo for us.\n- Report bugs.\n- Suggest additional features.\n\n## Licence\n\nDistributed under the Apache License 2.0. See `LICENSE` for more information.\n\n## Contact\n\nEmail - [nqabenhlemlaba22@gmail.com](mailto:nqabenhlemlaba22@gmail.com)\n\nInstagram - [instagram.com/asanda.que](https://instagram.com/asanda.que)\n\nGitHub - [github.com/lindelwa122](https://github.com/lindelwa122)\n\nLinkedIn - [linkedin/nqabenhle](https://linkedin.com/in/nqabenhle)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flindelwa122%2Fcolorful-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flindelwa122%2Fcolorful-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flindelwa122%2Fcolorful-test/lists"}