forked from pydsigner/python-lightningcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_process_stylesheet.py
More file actions
33 lines (23 loc) · 962 Bytes
/
test_process_stylesheet.py
File metadata and controls
33 lines (23 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import lightningcss as lcss
import pytest
def test_minify():
code = ".content { margin-inline: 3vw; padding: 1rem 2rem 1rem 2rem; }"
expected = ".content{margin-inline:3vw;padding:1rem 2rem}"
result = lcss.process_stylesheet(code)
assert result == expected
def test_pretty_print():
code = ".content { margin: 3vw; }"
expected = ".content {\n margin: 3vw;\n}\n"
result = lcss.process_stylesheet(code, minify=False)
assert result == expected
def test_parse_error():
code = "img { display: block; } nonsense }{ non-terminated"
with pytest.raises(ValueError):
lcss.process_stylesheet(code)
def test_error_recovery():
code = "img { display: block; } nonsense }{ non-terminated"
expected = "img{display:block}"
with pytest.raises(ValueError):
lcss.process_stylesheet(code, error_recovery=False)
result = lcss.process_stylesheet(code, error_recovery=True)
assert result == expected