Skip to content

Commit 0b4c9f6

Browse files
committed
Move QSS template reading tests to test_theme_utils
read_qss_stylesheet_file only names a resource and delegates to read_theming_resource, so its tests belong with the other resource loader tests rather than among the template processing ones.
1 parent 1f7cc99 commit 0b4c9f6

2 files changed

Lines changed: 26 additions & 25 deletions

File tree

tests/ert/unit_tests/gui/theme_manager/test_qss_processing.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from ert.gui.theme_manager.qss_processing import (
77
QssProcessingError,
88
process_qss,
9-
read_qss_stylesheet_file,
109
resolve_includes,
1110
substitute_tokens,
1211
)
@@ -78,30 +77,6 @@ def test_that_substitute_tokens_raises_for_placeholder_with_underscores() -> Non
7877
substitute_tokens("color: {{bg_canvas}};", {"bg-canvas": "#fff"})
7978

8079

81-
def test_that_read_qss_stylesheet_file_returns_template_content(
82-
monkeypatch: pytest.MonkeyPatch,
83-
) -> None:
84-
monkeypatch.setattr(
85-
qss_mod,
86-
"read_theming_resource",
87-
lambda *, filename, resource_kind: f"content-of-{filename}",
88-
)
89-
result = read_qss_stylesheet_file("main")
90-
assert result == "content-of-qss_stylesheet/main.qss.in"
91-
92-
93-
def test_that_read_qss_stylesheet_file_raises_file_not_found_for_missing_template(
94-
monkeypatch: pytest.MonkeyPatch,
95-
) -> None:
96-
def _raise(*, filename: str, resource_kind: str) -> str:
97-
raise FileNotFoundError(f"not found: {resource_kind}")
98-
99-
monkeypatch.setattr(qss_mod, "read_theming_resource", _raise)
100-
101-
with pytest.raises(FileNotFoundError, match=r"not found.*QSS template"):
102-
read_qss_stylesheet_file("missing")
103-
104-
10580
def test_that_process_qss_returns_fully_resolved_stylesheet(
10681
monkeypatch: pytest.MonkeyPatch,
10782
) -> None:

tests/ert/unit_tests/gui/theme_manager/test_theme_utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import pytest
44

55
from ert.gui.theme_manager import design_token as design_token_mod
6+
from ert.gui.theme_manager import qss_processing as qss_mod
67
from ert.gui.theme_manager import theme_utils
78
from ert.gui.theme_manager.design_token import read_design_token_file
9+
from ert.gui.theme_manager.qss_processing import read_qss_stylesheet_file
810
from ert.gui.theme_manager.theme_utils import ColorTheme, read_theming_resource
911

1012

@@ -62,3 +64,27 @@ def _raise(*, filename: str, resource_kind: str) -> str:
6264

6365
with pytest.raises(FileNotFoundError, match=r"not found.*design token"):
6466
read_design_token_file(ColorTheme.DARK)
67+
68+
69+
def test_that_read_qss_stylesheet_file_returns_template_content(
70+
monkeypatch: pytest.MonkeyPatch,
71+
) -> None:
72+
monkeypatch.setattr(
73+
qss_mod,
74+
"read_theming_resource",
75+
lambda *, filename, resource_kind: f"content-of-{filename}",
76+
)
77+
result = read_qss_stylesheet_file("main")
78+
assert result == "content-of-qss_stylesheet/main.qss.in"
79+
80+
81+
def test_that_read_qss_stylesheet_file_raises_file_not_found_for_missing_template(
82+
monkeypatch: pytest.MonkeyPatch,
83+
) -> None:
84+
def _raise(*, filename: str, resource_kind: str) -> str:
85+
raise FileNotFoundError(f"not found: {resource_kind}")
86+
87+
monkeypatch.setattr(qss_mod, "read_theming_resource", _raise)
88+
89+
with pytest.raises(FileNotFoundError, match=r"not found.*QSS template"):
90+
read_qss_stylesheet_file("missing")

0 commit comments

Comments
 (0)