-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_style.py
More file actions
58 lines (41 loc) · 1.59 KB
/
test_style.py
File metadata and controls
58 lines (41 loc) · 1.59 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Unit tests for StyleSheet and theming."""
from pythonnative.style import (
DEFAULT_DARK_THEME,
DEFAULT_LIGHT_THEME,
StyleSheet,
ThemeContext,
)
def test_stylesheet_create() -> None:
styles = StyleSheet.create(
heading={"font_size": 28, "bold": True},
body={"font_size": 16},
)
assert "heading" in styles
assert styles["heading"]["font_size"] == 28
assert styles["body"]["font_size"] == 16
def test_stylesheet_compose() -> None:
base = {"font_size": 16, "color": "#000"}
override = {"color": "#FFF", "bold": True}
merged = StyleSheet.compose(base, override)
assert merged["font_size"] == 16
assert merged["color"] == "#FFF"
assert merged["bold"] is True
def test_stylesheet_compose_none_safe() -> None:
result = StyleSheet.compose(None, {"a": 1}, None)
assert result == {"a": 1}
def test_stylesheet_flatten_dict() -> None:
result = StyleSheet.flatten({"font_size": 20})
assert result == {"font_size": 20}
def test_stylesheet_flatten_list() -> None:
result = StyleSheet.flatten([{"a": 1}, {"b": 2}])
assert result == {"a": 1, "b": 2}
def test_stylesheet_flatten_none() -> None:
result = StyleSheet.flatten(None)
assert result == {}
def test_theme_context_has_default() -> None:
val = ThemeContext._current()
assert val is DEFAULT_LIGHT_THEME
assert "primary_color" in val
def test_light_and_dark_themes_differ() -> None:
assert DEFAULT_LIGHT_THEME["background_color"] != DEFAULT_DARK_THEME["background_color"]
assert DEFAULT_LIGHT_THEME["text_color"] != DEFAULT_DARK_THEME["text_color"]