Skip to content

Commit ec20c7f

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 c13c96f commit ec20c7f

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
)
@@ -68,30 +67,6 @@ def test_that_substitute_tokens_raises_with_sorted_deduplicated_token_names() ->
6867
substitute_tokens(template, {})
6968

7069

71-
def test_that_read_qss_stylesheet_file_returns_template_content(
72-
monkeypatch: pytest.MonkeyPatch,
73-
) -> None:
74-
monkeypatch.setattr(
75-
qss_mod,
76-
"read_theming_resource",
77-
lambda *, filename, resource_kind: f"content-of-{filename}",
78-
)
79-
result = read_qss_stylesheet_file("main")
80-
assert result == "content-of-qss_stylesheet/main.qss.in"
81-
82-
83-
def test_that_read_qss_stylesheet_file_raises_file_not_found_for_missing_template(
84-
monkeypatch: pytest.MonkeyPatch,
85-
) -> None:
86-
def _raise(*, filename: str, resource_kind: str) -> str:
87-
raise FileNotFoundError(f"not found: {resource_kind}")
88-
89-
monkeypatch.setattr(qss_mod, "read_theming_resource", _raise)
90-
91-
with pytest.raises(FileNotFoundError, match=r"not found.*QSS template"):
92-
read_qss_stylesheet_file("missing")
93-
94-
9570
def test_that_process_qss_returns_fully_resolved_stylesheet(
9671
monkeypatch: pytest.MonkeyPatch,
9772
) -> 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)