File: test_colors.py

package info (click to toggle)
python-colorful 0.5.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,124 kB
  • sloc: python: 1,343; sh: 8; makefile: 3
file content (41 lines) | stat: -rw-r--r-- 956 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-

"""
    colorful
    ~~~~~~~~

    Terminal string styling done right, in Python.

    :copyright: (c) 2017 by Timo Furrer <tuxtimo@gmail.com>
    :license: MIT, see LICENSE for more details.
"""

import os

import pytest

# do not overwrite module
os.environ['COLORFUL_NO_MODULE_OVERWRITE'] = '1'

import colorful.colors as colors  # noqa


@pytest.mark.parametrize('colorpalette, expected', [
    ({'black': '#000000'}, {'black': (0, 0, 0)}),
    ({'red': '#FF0000'}, {'red': (255, 0, 0)}),
    ({'purple': '#800080'}, {'purple': (128, 0, 128)}),
    ({
        'maroon': '#800000',
        'magenta': '#FF00FF',
        'cyan': '#00FFFF'
    }, {
        'maroon': (128, 0, 0),
        'magenta': (255, 0, 255),
        'cyan': (0, 255, 255)
    })
])
def test_sanitize_color_palette(colorpalette, expected):
    """
    Test sanitizing a color palette
    """
    assert colors.sanitize_color_palette(colorpalette) == expected