customcolor


Namecustomcolor JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/gimpelgit/customcolor/
SummaryLibrary for colored output of unit tests in the console
upload_time2024-10-11 19:38:52
maintainerNone
docs_urlNone
authorKirill
requires_python>=3.6
licenseMIT
keywords unittest colour color output print windows linux text-decoration
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [**English**](https://github.com/gimpelgit/customcolor/blob/main/README.md) | [Русский](https://github.com/gimpelgit/customcolor/blob/main/README-ru.md)

# Customcolor

[![license](https://img.shields.io/pypi/l/customcolor.svg)](https://pypi.org/project/customcolor/)
[![Current version on PyPI](http://img.shields.io/pypi/v/customcolor.svg)](https://pypi.org/project/customcolor/)
[![python versions](https://img.shields.io/pypi/pyversions/customcolor.svg)](https://pypi.org/project/customcolor/)

```Customcolor``` is a library for colorful output of test run information in the console when using Python's built-in ```unittest``` module.

If you're not using PyCharm but, for example, an environment like VS Code, you may have noticed that with a large number of tests, it can be difficult to quickly spot which test has failed. Moreover, it might be hard to see where the output of the failed test ends. This can make it harder to analyze test results and identify issues. That's why you might want to use the ```customcolor``` library.

## Platforms

```Customcolor``` is designed for use on Windows and Linux operating systems.

You may also try to use it on macOS, though it hasn't been tested there. If you manage to get it running, let me know — I'd be happy to update this section!

## Installation

Downloading ```customcolor``` is easy since it's available on PyPI. You can install it with the following command:

```console
pip install customcolor
```

## Usage

In essence, all the library does is create a ```ColorTestRunner``` class, which you can pass to the standard ```unittest.main()``` function.

### Example

Suppose your project has the following structure:

![](https://raw.githubusercontent.com/gimpelgit/customcolor/refs/heads/main/img/testproj.png)

And the file ```test_calc.py``` contains the following code:

```py
import unittest
from customcolor.runner import ColorTestRunner

from utils.calc import *


class MyTest(unittest.TestCase):
    def test_failed(self):
        """Test that fails"""
        self.assertEqual(add(3, 6), 11)


    def test_error(self):
        """Test that raises an error"""
        raise ValueError("Unexpected error")


    def test_ok(self):
        """Test that passes"""
        self.assertEqual(add(2, 2), 4)


if __name__ == "__main__":
    unittest.main(testRunner=ColorTestRunner(verbosity=2))
```

If you run the test the usual way, like this:

```console
python -m unittest -v tests.test_calc
```

you won't see colored output. This is because in this case, ```unittest``` uses the default classes ```TextTestRunner``` and ```TextTestResult```.

To **run the test with colored output**, you should use the command:

```console
python -m tests.test_calc
```

### Output without the library vs with the library

|   |   |
|---|---|
|<img src="https://raw.githubusercontent.com/gimpelgit/customcolor/refs/heads/main/img/en-old.png" width="350">|<img src="https://raw.githubusercontent.com/gimpelgit/customcolor/refs/heads/main/img/en-new.png" width="350">|


## Additional Features

Since this library has no dependencies and is written entirely in pure Python, it includes color print functions, which are wrappers around the standard ```print``` function.

This means if you install the library, you can use colored console output without needing to install any additional modules. However, the number of available colors might be limited for your needs.

### Example

```py
from customcolor.colors import *


print_dark_yellow("DARK_YELLOW")
print_yellow("YELLOW")
print_gray("GRAY")
print_light_gray("LIGHT_GRAY")
print_white("WHITE")
print_black("BLACK")
print_dark_blue("DARK_BLUE")
print_blue("BLUE")
print_dark_red("DARK_RED")
print_red("RED")
print_dark_green("DARK_GREEN")
print_green("GREEN")
print_dark_magenta("DARK_MAGENTA")
print_magenta("MAGENTA")
print_dark_cyan("DARK_CYAN")
print_cyan("CYAN")

color_print("GREEN", color=TextColor.GREEN)
```

### Output in cmd

<img src="https://raw.githubusercontent.com/gimpelgit/customcolor/refs/heads/main/img/print_func.png" width="130">


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gimpelgit/customcolor/",
    "name": "customcolor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "unittest colour color output print windows linux text-decoration",
    "author": "Kirill",
    "author_email": "gimpelcomp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0b/86/e914a2c587d92ae0d625546c95f7339f2bdf29160d9199eef781ac6a5076/customcolor-0.0.4.tar.gz",
    "platform": null,
    "description": "[**English**](https://github.com/gimpelgit/customcolor/blob/main/README.md) | [\u0420\u0443\u0441\u0441\u043a\u0438\u0439](https://github.com/gimpelgit/customcolor/blob/main/README-ru.md)\r\n\r\n# Customcolor\r\n\r\n[![license](https://img.shields.io/pypi/l/customcolor.svg)](https://pypi.org/project/customcolor/)\r\n[![Current version on PyPI](http://img.shields.io/pypi/v/customcolor.svg)](https://pypi.org/project/customcolor/)\r\n[![python versions](https://img.shields.io/pypi/pyversions/customcolor.svg)](https://pypi.org/project/customcolor/)\r\n\r\n```Customcolor``` is a library for colorful output of test run information in the console when using Python's built-in ```unittest``` module.\r\n\r\nIf you're not using PyCharm but, for example, an environment like VS Code, you may have noticed that with a large number of tests, it can be difficult to quickly spot which test has failed. Moreover, it might be hard to see where the output of the failed test ends. This can make it harder to analyze test results and identify issues. That's why you might want to use the ```customcolor``` library.\r\n\r\n## Platforms\r\n\r\n```Customcolor``` is designed for use on Windows and Linux operating systems.\r\n\r\nYou may also try to use it on macOS, though it hasn't been tested there. If you manage to get it running, let me know \u2014 I'd be happy to update this section!\r\n\r\n## Installation\r\n\r\nDownloading ```customcolor``` is easy since it's available on PyPI. You can install it with the following command:\r\n\r\n```console\r\npip install customcolor\r\n```\r\n\r\n## Usage\r\n\r\nIn essence, all the library does is create a ```ColorTestRunner``` class, which you can pass to the standard ```unittest.main()``` function.\r\n\r\n### Example\r\n\r\nSuppose your project has the following structure:\r\n\r\n![](https://raw.githubusercontent.com/gimpelgit/customcolor/refs/heads/main/img/testproj.png)\r\n\r\nAnd the file ```test_calc.py``` contains the following code:\r\n\r\n```py\r\nimport unittest\r\nfrom customcolor.runner import ColorTestRunner\r\n\r\nfrom utils.calc import *\r\n\r\n\r\nclass MyTest(unittest.TestCase):\r\n    def test_failed(self):\r\n        \"\"\"Test that fails\"\"\"\r\n        self.assertEqual(add(3, 6), 11)\r\n\r\n\r\n    def test_error(self):\r\n        \"\"\"Test that raises an error\"\"\"\r\n        raise ValueError(\"Unexpected error\")\r\n\r\n\r\n    def test_ok(self):\r\n        \"\"\"Test that passes\"\"\"\r\n        self.assertEqual(add(2, 2), 4)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    unittest.main(testRunner=ColorTestRunner(verbosity=2))\r\n```\r\n\r\nIf you run the test the usual way, like this:\r\n\r\n```console\r\npython -m unittest -v tests.test_calc\r\n```\r\n\r\nyou won't see colored output. This is because in this case, ```unittest``` uses the default classes ```TextTestRunner``` and ```TextTestResult```.\r\n\r\nTo **run the test with colored output**, you should use the command:\r\n\r\n```console\r\npython -m tests.test_calc\r\n```\r\n\r\n### Output without the library vs with the library\r\n\r\n|   |   |\r\n|---|---|\r\n|<img src=\"https://raw.githubusercontent.com/gimpelgit/customcolor/refs/heads/main/img/en-old.png\" width=\"350\">|<img src=\"https://raw.githubusercontent.com/gimpelgit/customcolor/refs/heads/main/img/en-new.png\" width=\"350\">|\r\n\r\n\r\n## Additional Features\r\n\r\nSince this library has no dependencies and is written entirely in pure Python, it includes color print functions, which are wrappers around the standard ```print``` function.\r\n\r\nThis means if you install the library, you can use colored console output without needing to install any additional modules. However, the number of available colors might be limited for your needs.\r\n\r\n### Example\r\n\r\n```py\r\nfrom customcolor.colors import *\r\n\r\n\r\nprint_dark_yellow(\"DARK_YELLOW\")\r\nprint_yellow(\"YELLOW\")\r\nprint_gray(\"GRAY\")\r\nprint_light_gray(\"LIGHT_GRAY\")\r\nprint_white(\"WHITE\")\r\nprint_black(\"BLACK\")\r\nprint_dark_blue(\"DARK_BLUE\")\r\nprint_blue(\"BLUE\")\r\nprint_dark_red(\"DARK_RED\")\r\nprint_red(\"RED\")\r\nprint_dark_green(\"DARK_GREEN\")\r\nprint_green(\"GREEN\")\r\nprint_dark_magenta(\"DARK_MAGENTA\")\r\nprint_magenta(\"MAGENTA\")\r\nprint_dark_cyan(\"DARK_CYAN\")\r\nprint_cyan(\"CYAN\")\r\n\r\ncolor_print(\"GREEN\", color=TextColor.GREEN)\r\n```\r\n\r\n### Output in cmd\r\n\r\n<img src=\"https://raw.githubusercontent.com/gimpelgit/customcolor/refs/heads/main/img/print_func.png\" width=\"130\">\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Library for colored output of unit tests in the console",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/gimpelgit/customcolor/"
    },
    "split_keywords": [
        "unittest",
        "colour",
        "color",
        "output",
        "print",
        "windows",
        "linux",
        "text-decoration"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fd11b697068fcd3b197802195517b740e6f501f4d77de9e339a90886193c958e",
                "md5": "3fd815d3da9fa26f389b8bf57fc3e73b",
                "sha256": "555be7b959851a44299809f0509abcbe5b1a166160e11be3028e6fb0441cce89"
            },
            "downloads": -1,
            "filename": "customcolor-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3fd815d3da9fa26f389b8bf57fc3e73b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 7673,
            "upload_time": "2024-10-11T19:38:51",
            "upload_time_iso_8601": "2024-10-11T19:38:51.192253Z",
            "url": "https://files.pythonhosted.org/packages/fd/11/b697068fcd3b197802195517b740e6f501f4d77de9e339a90886193c958e/customcolor-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b86e914a2c587d92ae0d625546c95f7339f2bdf29160d9199eef781ac6a5076",
                "md5": "f2eb3bc5d7ba8bf2a689815783d228a4",
                "sha256": "cc94c5d2a41ce51b2dbe8a9b092964f245558e745de6c20a8320b4ce13925ebe"
            },
            "downloads": -1,
            "filename": "customcolor-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "f2eb3bc5d7ba8bf2a689815783d228a4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7685,
            "upload_time": "2024-10-11T19:38:52",
            "upload_time_iso_8601": "2024-10-11T19:38:52.918810Z",
            "url": "https://files.pythonhosted.org/packages/0b/86/e914a2c587d92ae0d625546c95f7339f2bdf29160d9199eef781ac6a5076/customcolor-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-11 19:38:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gimpelgit",
    "github_project": "customcolor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "customcolor"
}
        
Elapsed time: 0.32842s