summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-03-10 20:49:44 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-03-10 20:51:27 +0100
commit27fcfcdbd25ed7136773f6bd99cd317c89af93d6 (patch)
tree1e5bd568cb52c5422d7ca7b5df4cd75dcc6033e5 /tests
parent6c67f927c8922f0bcf25b524dfb4a72455625f93 (diff)
downloadqutebrowser-27fcfcdbd25ed7136773f6bd99cd317c89af93d6.tar.gz
qutebrowser-27fcfcdbd25ed7136773f6bd99cd317c89af93d6.zip
Fix issues with locale workaround
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/config/test_qtargs.py16
-rw-r--r--tests/unit/config/test_qtargs_locale_workaround.py9
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/unit/config/test_qtargs.py b/tests/unit/config/test_qtargs.py
index e7dbd5d95..695649213 100644
--- a/tests/unit/config/test_qtargs.py
+++ b/tests/unit/config/test_qtargs.py
@@ -530,6 +530,22 @@ class TestWebEngineArgs:
for arg in expected:
assert arg in args
+ @pytest.mark.linux
+ def test_locale_workaround(self, config_stub, monkeypatch, version_patcher,
+ parser):
+ class FakeLocale:
+
+ def bcp47Name(self):
+ return 'de-CH'
+
+ monkeypatch.setattr(qtargs.objects, 'backend', usertypes.Backend.QtWebEngine)
+ monkeypatch.setattr(qtargs, 'QLocale', FakeLocale)
+ version_patcher('5.15.3')
+ config_stub.val.qt.workarounds.locale = True
+ parsed = parser.parse_args([])
+ args = qtargs.qt_args(parsed)
+ assert '--lang=de' in args
+
class TestEnvVars:
diff --git a/tests/unit/config/test_qtargs_locale_workaround.py b/tests/unit/config/test_qtargs_locale_workaround.py
index 977118198..073e08c03 100644
--- a/tests/unit/config/test_qtargs_locale_workaround.py
+++ b/tests/unit/config/test_qtargs_locale_workaround.py
@@ -403,6 +403,7 @@ def qtwe_version():
("zh_XX.UTF-8", "zh-CN"), # locale not available on my system
("zu_ZA.UTF-8", "en-US"),
])
+@pytest.mark.linux
def test_lang_workaround_all_locales(lang, expected, qtwe_version):
locale_name = QLocale(lang).bcp47Name()
print(locale_name)
@@ -444,3 +445,11 @@ def test_non_linux(qtwe_version):
def test_disabled(qtwe_version, config_stub):
config_stub.val.qt.workarounds.locale = False
assert qtargs._get_lang_override(qtwe_version, "de-CH") is None
+
+
+@pytest.mark.fake_os('linux')
+def test_no_locales_available(qtwe_version, monkeypatch, caplog):
+ monkeypatch.setattr(qtargs.QLibraryInfo, 'location', lambda _path: '/doesnotexist')
+ assert qtargs._get_lang_override(qtwe_version, "de-CH") is None
+ assert caplog.messages == [
+ "/doesnotexist/qtwebengine_locales not found, skipping workaround!"]