Skip to main content

test_vendor_css_files.py

1"""
2Tests for `vendor_css_files`.
3"""
5import pytest
7from vendor_css_files import get_colour_variable
10@pytest.mark.parametrize(
11 "css, name, colour",
12 [
13 # Simplest case
14 ("--red: #ff0000;", "red", "#ff0000"),
15 # Variable whitespace between varname and hex string
16 ("--red: #ff0000;", "red", "#ff0000"),
17 # Alpha channel
18 ("--red: #ff0000ff;", "red", "#ff0000ff"),
19 # Three-digit hex in source
20 ("--grey: #999;", "grey", "#999999"),
21 ],
23def test_get_colour_variable(css: str, name: str, colour: str) -> None:
24 """
25 Extract colour variables from CSS.
26 """
27 assert get_colour_variable(css, name=name) == colour