summaryrefslogtreecommitdiff
path: root/qutebrowser
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2024-04-30 22:47:04 +0200
committerFlorian Bruhin <me@the-compiler.org>2024-04-30 23:31:58 +0200
commit9c901b21017a6c2321771644d97aa0dd4d8a62fa (patch)
treec2899e80f287fe2d5ccf0520b6c1a6215b1cee9b /qutebrowser
parent9320c8f2e5610750ac8f35823f3338fe47824d41 (diff)
downloadqutebrowser-9c901b21017a6c2321771644d97aa0dd4d8a62fa.tar.gz
qutebrowser-9c901b21017a6c2321771644d97aa0dd4d8a62fa.zip
Add more dark mode logic unit tests
Diffstat (limited to 'qutebrowser')
-rw-r--r--qutebrowser/browser/webengine/darkmode.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/qutebrowser/browser/webengine/darkmode.py b/qutebrowser/browser/webengine/darkmode.py
index 52bf0f24d..8f1908547 100644
--- a/qutebrowser/browser/webengine/darkmode.py
+++ b/qutebrowser/browser/webengine/darkmode.py
@@ -113,6 +113,11 @@ Qt 6.6
- New alternative image classifier:
https://chromium-review.googlesource.com/c/chromium/src/+/3987823
+
+Qt 6.7
+------
+
+Enabling dark mode can now be done at runtime via QWebEngineSettings.
"""
import os
@@ -192,11 +197,6 @@ _BOOLS = {
False: 'false',
}
-_INT_BOOLS = {
- True: '1',
- False: '0',
-}
-
@dataclasses.dataclass
class _Setting:
@@ -265,16 +265,6 @@ class _Definition:
switch = self._switch_names.get(setting.option, self._switch_names[None])
yield switch, setting.with_prefix(self.prefix)
- def copy_with(self, attr: str, value: Any) -> '_Definition':
- """Get a new _Definition object with a changed attribute.
-
- NOTE: This does *not* copy the settings list. Both objects will reference the
- same (immutable) tuple.
- """
- new = copy.copy(self)
- setattr(new, attr, value)
- return new
-
def copy_add_setting(self, setting: _Setting) -> '_Definition':
"""Get a new _Definition object with an additional setting."""
new = copy.copy(self)
@@ -285,13 +275,15 @@ class _Definition:
"""Get a new _Definition object with a setting removed."""
new = copy.copy(self)
filtered_settings = tuple(s for s in self._settings if s.option != name)
+ if len(filtered_settings) == len(self._settings):
+ raise ValueError(f"Setting {name} not found in {self}")
new._settings = filtered_settings # pylint: disable=protected-access
return new
def copy_replace_setting(self, option: str, chromium_key: str) -> '_Definition':
"""Get a new _Definition object with `old` replaced by `new`.
- If `old` is not in the settings list, return the old _Definition object.
+ If `old` is not in the settings list, raise ValueError.
"""
new = copy.deepcopy(self)