diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/python/prompt-toolkit/py3/tests/test_style_transformation.py | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/tests/test_style_transformation.py')
-rw-r--r-- | contrib/python/prompt-toolkit/py3/tests/test_style_transformation.py | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/contrib/python/prompt-toolkit/py3/tests/test_style_transformation.py b/contrib/python/prompt-toolkit/py3/tests/test_style_transformation.py index af0eefcf0de..1193649e346 100644 --- a/contrib/python/prompt-toolkit/py3/tests/test_style_transformation.py +++ b/contrib/python/prompt-toolkit/py3/tests/test_style_transformation.py @@ -1,49 +1,49 @@ -import pytest - -from prompt_toolkit.styles import AdjustBrightnessStyleTransformation, Attrs - - -@pytest.fixture -def default_attrs(): - return Attrs( - color="", - bgcolor="", - bold=False, - underline=False, - strike=False, - italic=False, - blink=False, - reverse=False, - hidden=False, - ) - - -def test_adjust_brightness_style_transformation(default_attrs): - tr = AdjustBrightnessStyleTransformation(0.5, 1.0) - - attrs = tr.transform_attrs(default_attrs._replace(color="ff0000")) - assert attrs.color == "ff7f7f" - - attrs = tr.transform_attrs(default_attrs._replace(color="00ffaa")) - assert attrs.color == "7fffd4" - - # When a background color is given, nothing should change. - attrs = tr.transform_attrs(default_attrs._replace(color="00ffaa", bgcolor="white")) - assert attrs.color == "00ffaa" - - # Test ansi colors. - attrs = tr.transform_attrs(default_attrs._replace(color="ansiblue")) - assert attrs.color == "6666ff" - - # Test 'ansidefault'. This shouldn't change. - attrs = tr.transform_attrs(default_attrs._replace(color="ansidefault")) - assert attrs.color == "ansidefault" - - # When 0 and 1 are given, don't do any style transformation. - tr2 = AdjustBrightnessStyleTransformation(0, 1) - - attrs = tr2.transform_attrs(default_attrs._replace(color="ansiblue")) - assert attrs.color == "ansiblue" - - attrs = tr2.transform_attrs(default_attrs._replace(color="00ffaa")) - assert attrs.color == "00ffaa" +import pytest + +from prompt_toolkit.styles import AdjustBrightnessStyleTransformation, Attrs + + +@pytest.fixture +def default_attrs(): + return Attrs( + color="", + bgcolor="", + bold=False, + underline=False, + strike=False, + italic=False, + blink=False, + reverse=False, + hidden=False, + ) + + +def test_adjust_brightness_style_transformation(default_attrs): + tr = AdjustBrightnessStyleTransformation(0.5, 1.0) + + attrs = tr.transform_attrs(default_attrs._replace(color="ff0000")) + assert attrs.color == "ff7f7f" + + attrs = tr.transform_attrs(default_attrs._replace(color="00ffaa")) + assert attrs.color == "7fffd4" + + # When a background color is given, nothing should change. + attrs = tr.transform_attrs(default_attrs._replace(color="00ffaa", bgcolor="white")) + assert attrs.color == "00ffaa" + + # Test ansi colors. + attrs = tr.transform_attrs(default_attrs._replace(color="ansiblue")) + assert attrs.color == "6666ff" + + # Test 'ansidefault'. This shouldn't change. + attrs = tr.transform_attrs(default_attrs._replace(color="ansidefault")) + assert attrs.color == "ansidefault" + + # When 0 and 1 are given, don't do any style transformation. + tr2 = AdjustBrightnessStyleTransformation(0, 1) + + attrs = tr2.transform_attrs(default_attrs._replace(color="ansiblue")) + assert attrs.color == "ansiblue" + + attrs = tr2.transform_attrs(default_attrs._replace(color="00ffaa")) + assert attrs.color == "00ffaa" |