<commit_before># -*- coding: utf-8 -*-
#
# Copyright (c) 2016 -- <NAME> - Semagia <http://www.semagia.com/>.
# All rights reserved.
#
# License: BSD License
#
"""\
Tests against the colors module.

:author:       <NAME> (heuer[at]semagia.com)
:organization: Semagia - http://www.semagia.com/
:license:      BSD License
"""
from __future__ import absolute_import, unicode_literals
import pytest
from segno import colors


def test_illegal():
    with pytest.raises(ValueError):
        colors.color_to_rgb('unknown')


def test_illegal2():
    with pytest.raises(ValueError):
        colors.color_to_rgb((1, 2, 3, 256))


def test_illegal3():
    with pytest.raises(ValueError):
        colors.color_to_rgb((300, 300, 300))


def test_illegal4():
    with pytest.raises(ValueError):
        colors.color_to_rgb((0, 0, 256))


def test_illegal5():
    with pytest.raises(ValueError):
        colors.color_to_rgb((256, 0, 0))


def test_color_is_black():
    data = (((0, 0, 0, 0), False),
            ((0, 0, 0, 1), True),
            ((0, 0, 0, 1.0), True),
            ((0, 0, 0, 255), True),
            ((0, 0, 0, 0.25), False),
            ('#000', True),
            ('#000000', True),
            ('Black', True),
            ('black', True),
            ('BLACK', True),
            ('blacK', True),
            )

    def check(expected, clr):
        assert expected == colors.color_is_black(clr)

    for clr, expected in data:
        yield check, expected, clr


def test_color_is_white():
    data = (((255, 255, 255, 0), False),<commit_msg>Added test case that to_rgb raises an error if a color with an alpha channel is provided<commit_after># -*- coding: utf-8 -*-
#
# Copyright (c) 2016 -- <NAME> - Semagia <http://www.semagia.com/>.
# All rights reserved.
#
# License: BSD License
#
"""\
Tests against the colors module.

:author:       <NAME> (heuer[at]semagia.com)
:organization: Semagia - http://www.semagia.com/
:license:      BSD License
"""
from __future__ import absolute_import, unicode_literals
import pytest
from segno import colors


def test_illegal():
    with pytest.raises(ValueError):
        colors.color_to_rgb('unknown')


def test_illegal2():
    with pytest.raises(ValueError):
        colors.color_to_rgb((1, 2, 3, 256))


def test_illegal3():
    with pytest.raises(ValueError):
        colors.color_to_rgb((300, 300, 300))


def test_illegal4():
    with pytest.raises(ValueError):
        colors.color_to_rgb((0, 0, 256))


def test_illegal5():
    with pytest.raises(ValueError):
        colors.color_to_rgb((256, 0, 0))


def test_rgba_vs_rgb_conflict():
    with pytest.raises(ValueError):
        colors.color_to_rgb('#949494E8')


def test_color_is_black():
    data = (((0, 0, 0, 0), False),
            ((0, 0, 0, 1), True),
            ((0, 0, 0, 1.0), True),
            ((0, 0, 0, 255), True),
            ((0, 0, 0, 0.25), False),
            ('#000', True),
            ('#000000', True),
            ('Black', True),
            ('black', True),
            ('BLACK', True),
            ('blacK', True),
            )

    def check(expected, clr):
        assert expected == colors.color_is_black(clr)

    for clr, expected in data:
        yield check, expected, clr


def test_color_is_white():
    data = (((255, 255, 255, 0), False),
{'fraction_non_alphanumeric': 0.15699969632553903, 'fraction_numerical': 0.04949893713938658, 'mean_word_length': 2.5726681127982647, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2185166', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1124, 'n_words': 294}