File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8787 name : wheels-${{ runner.os }}-${{ matrix.target }}
8888 path : dist/*
8989
90+ test :
91+ name : Test wheels on ${{ matrix.os }} (${{ matrix.python-version }})
92+ needs : linux
93+ runs-on : ${{ matrix.os }}
94+ strategy :
95+ matrix :
96+ os : [ubuntu-latest]
97+ python-version : ['3.10']
98+ steps :
99+ - uses : actions/checkout@v4
100+ - name : Set up Python ${{ matrix.python-version }}
101+ uses : actions/setup-python@v5
102+ with :
103+ python-version : ${{ matrix.python-version }}
104+ - name : Download x86_64 wheels
105+ uses : actions/download-artifact@v4
106+ with :
107+ name : wheels-Linux-x86_64
108+ path : dist
109+ - name : Install wheel and dependencies
110+ run : |
111+ pip install --upgrade pip
112+ pip install --no-index --find-links=dist lightningcss
113+ pip install --group dev
114+ - name : Run tests
115+ run : pytest
116+
90117 sdist :
91118 runs-on : ubuntu-latest
92119 steps :
Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ classifiers = [
3737[project .urls ]
3838Source = " https://github.com/pydsigner/python-lightningcss"
3939
40+ [dependency-groups ]
41+ dev = [
42+ " pytest>=9.0.2" ,
43+ ]
4044
4145[tool .maturin ]
4246features = [" pyo3/extension-module" ]
Original file line number Diff line number Diff line change 1+ * {
2+ box-sizing : border-box;
3+ }
4+
5+ something invalid
Original file line number Diff line number Diff line change 1+ @import "normalize.css" layer(normalize);
2+
3+ a {
4+ color : blue;
5+ }
Original file line number Diff line number Diff line change 1+ * {
2+ box-sizing : border-box;
3+ }
Original file line number Diff line number Diff line change 1+ from pathlib import Path
2+ import pytest
3+ import lightningcss as lcss
4+
5+ TEST_DATA_DIR = Path (__file__ ).parent / "data"
6+ MAIN_CSS_PATH = TEST_DATA_DIR / "main.css"
7+ NORMALIZE_CSS_PATH = TEST_DATA_DIR / "normalize.css"
8+ MISSING_CSS_PATH = TEST_DATA_DIR / "not-there.css"
9+ INVALID_CSS_PATH = TEST_DATA_DIR / "invalid.css"
10+
11+
12+ def test_minify ():
13+ expected = "@layer normalize{*{box-sizing:border-box}}a{color:#00f}"
14+
15+ result = lcss .bundle_css (str (MAIN_CSS_PATH ))
16+ assert result == expected
17+
18+ def test_pretty_print ():
19+ expected = "* {\n box-sizing: border-box;\n }\n "
20+
21+ result = lcss .bundle_css (str (NORMALIZE_CSS_PATH ), minify = False )
22+ assert result == expected
23+
24+ def test_file_not_found ():
25+ with pytest .raises (OSError ):
26+ lcss .bundle_css (str (MISSING_CSS_PATH ))
27+
28+ def test_parse_error ():
29+ with pytest .raises (ValueError ):
30+ lcss .bundle_css (str (INVALID_CSS_PATH ))
Original file line number Diff line number Diff line change 1+ import lightningcss as lcss
2+ import pytest
3+
4+
5+ def test_minify ():
6+ code = ".content { margin-inline: 3vw; padding: 1rem 2rem 1rem 2rem; }"
7+ expected = ".content{margin-inline:3vw;padding:1rem 2rem}"
8+
9+ result = lcss .process_stylesheet (code )
10+ assert result == expected
11+
12+ def test_pretty_print ():
13+ code = ".content { margin: 3vw; }"
14+ expected = ".content {\n margin: 3vw;\n }\n "
15+
16+ result = lcss .process_stylesheet (code , minify = False )
17+ assert result == expected
18+
19+ def test_parse_error ():
20+ code = "img { display: block; } nonsense }{ non-terminated"
21+
22+ with pytest .raises (ValueError ):
23+ lcss .process_stylesheet (code )
24+
25+ def test_error_recovery ():
26+ code = "img { display: block; } nonsense }{ non-terminated"
27+ expected = "img{display:block}"
28+
29+ with pytest .raises (ValueError ):
30+ lcss .process_stylesheet (code , error_recovery = False )
31+
32+ result = lcss .process_stylesheet (code , error_recovery = True )
33+ assert result == expected
You can’t perform that action at this time.
0 commit comments