Esempio n. 1
0
def test_config_set_flag_json() -> None:
    config = Config()
    config.set_flags(json=False)
    assert config.always_output_json is False

    config = Config()
    config.set_flags(json=True)
    assert config.always_output_json is True
Esempio n. 2
0
def test_config_set_flag_units() -> None:
    config = Config()
    config.set_flags(units=False)
    assert config.display_degree_symbol is False
    assert config.display_percent_symbol is False

    config = Config()
    config.set_flags(units=True)
    assert config.display_degree_symbol is True
    assert config.display_percent_symbol is True
Esempio n. 3
0
def test_config_set_flag_shades() -> None:
    config = Config()
    config.set_flags(shades=True)
    assert config.default_shades_count == DEFAULT_SHADES_COUNT

    config = Config()
    config.set_flags(shades=False)
    assert config.default_shades_count == 0

    config = Config()
    config.set_flags(shades=None)
    assert config.default_shades_count == 15

    config = Config()
    config.set_flags(shades=10)
    assert config.default_shades_count == 10
Esempio n. 4
0
def test_config_set_flag_all() -> None:
    config = Config()
    view_keys = frozenset(("name", "hex"))
    config.get_view_keys = view_keys
    config.list_view_keys = view_keys
    config.json_keys = view_keys

    config.set_flags(all=None)
    assert config.get_view_keys == view_keys
    assert config.list_view_keys == view_keys
    assert config.json_keys == view_keys

    config.set_flags(all=False)
    assert config.get_view_keys == view_keys
    assert config.list_view_keys == view_keys
    assert config.json_keys == view_keys

    config.set_flags(all=True)
    assert config.get_view_keys == VIEW_KEYS
    assert config.list_view_keys == VIEW_KEYS
    assert config.json_keys == JSON_KEYS
Esempio n. 5
0
    format_hex,
    format_hsl,
    format_hsv,
    format_list_view,
    format_name,
    format_rgb,
)

default_config = Config()

custom_config = Config()
custom_config.uppercase_hex_codes = False
custom_config.get_view_keys = frozenset(("name", "hex"))
custom_config.list_view_keys = frozenset(("name", "hex"))
custom_config.approx_name_suffix = "*"
custom_config.set_flags(units=True)


@pytest.mark.parametrize(
    ("c", "m", "y", "k", "expected"),
    (
        (0.000, 0.010, 0.020, 0.030, "C:0   M:1   Y:2   K:3  "),
        (0.104, 0.204, 0.304, 0.404, "C:10  M:20  Y:30  K:40 "),
        (0.106, 0.206, 0.306, 0.406, "C:11  M:21  Y:31  K:41 "),
        (1.000, 1.000, 1.000, 1.000, "C:100 M:100 Y:100 K:100"),
    ),
)
def test_format_cmyk(c, m, y, k, expected):
    assert format_cmyk(default_config, c, m, y, k) == expected