diff --git a/tests/end2end/conftest.py b/tests/end2end/conftest.py index d3d34097b..5226396a3 100644 --- a/tests/end2end/conftest.py +++ b/tests/end2end/conftest.py @@ -118,27 +118,6 @@ def _get_backend_tag(tag): return pytest_marks[name](desc) -def _get_dictionary_tag(tag): - """Handle tags like must_have_dict=en-US for BDD tests.""" - dict_re = re.compile(r""" - (?Pmust_have_dict|cannot_have_dict)=(?P[a-z]{2}-[A-Z]{2}) - """, re.VERBOSE) - - match = dict_re.fullmatch(tag) - if not match: - return None - - event = match.group('event') - dictionary = match.group('dict') - has_dict = spell.local_filename(dictionary) is not None - if event == 'must_have_dict': - return pytest.mark.skipif(not has_dict, reason=tag) - elif event == 'cannot_have_dict': - return pytest.mark.skipif(has_dict, reason=tag) - else: - return None - - if not getattr(sys, 'frozen', False): def pytest_bdd_apply_tag(tag, function): """Handle custom tags for BDD tests. @@ -146,7 +125,7 @@ if not getattr(sys, 'frozen', False): This tries various functions, and if none knows how to handle this tag, it returns None so it falls back to pytest-bdd's implementation. """ - funcs = [_get_version_tag, _get_backend_tag, _get_dictionary_tag] + funcs = [_get_version_tag, _get_backend_tag] for func in funcs: mark = func(tag) if mark is not None: diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index e15af8ad5..aaad14530 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -568,16 +568,4 @@ Feature: Various utility commands. Scenario: Simple adblock update When I set up "simple" as block lists And I run :adblock-update - Then the message "adblock: Read 1 hosts from 1 sources." should be shown - - ## Spellcheck - - @qtwebkit_skip @qt>=5.8 @cannot_have_dict=af-ZA - Scenario: Set valid but not installed language - When I run :set spellcheck.languages ['af-ZA'] - Then the warning "Language af-ZA is not installed *" should be shown - - @qtwebkit_skip @qt>=5.8 @must_have_dict=en-US - Scenario: Set valid and installed language - When I run :set spellcheck.languages ["en-US"] - Then the option spellcheck.languages should be set to ["en-US"] + Then the message "adblock: Read 1 hosts from 1 sources." should be shown \ No newline at end of file diff --git a/tests/unit/browser/webengine/test_webenginesettings.py b/tests/unit/browser/webengine/test_webenginesettings.py index 1fbe38f00..fab2a9847 100644 --- a/tests/unit/browser/webengine/test_webenginesettings.py +++ b/tests/unit/browser/webengine/test_webenginesettings.py @@ -17,16 +17,22 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +import types +import logging + import pytest pytest.importorskip('PyQt5.QtWebEngineWidgets') from qutebrowser.browser.webengine import webenginesettings +from qutebrowser.utils import usertypes, qtutils @pytest.fixture(autouse=True) -def init_profiles(qapp, config_stub, cache_tmpdir, data_tmpdir): - webenginesettings._init_profiles() +def init(qapp, config_stub, cache_tmpdir, data_tmpdir): + init_args = types.SimpleNamespace(enable_webengine_inspector=False) + webenginesettings.init(init_args) + config_stub.changed.disconnect(webenginesettings._update_settings) def test_big_cache_size(config_stub): @@ -37,3 +43,32 @@ def test_big_cache_size(config_stub): webenginesettings._set_http_cache_size(profile) assert profile.httpCacheMaximumSize() == 2 ** 31 - 1 + + +@pytest.mark.skipif( + not qtutils.version_check('5.8'), reason="Needs Qt 5.8 or newer") +def test_non_existing_dict(config_stub, monkeypatch, message_mock, caplog): + monkeypatch.setattr(webenginesettings.spell, 'local_filename', + lambda _code: None) + config_stub.val.spellcheck.languages = ['af-ZA'] + + with caplog.at_level(logging.WARNING): + webenginesettings._update_settings('spellcheck.languages') + + msg = message_mock.getmsg(usertypes.MessageLevel.warning) + expected = ("Language af-ZA is not installed - see scripts/dictcli.py in " + "qutebrowser's sources") + assert msg.text == expected + + +@pytest.mark.skipif( + not qtutils.version_check('5.8'), reason="Needs Qt 5.8 or newer") +def test_existing_dict(config_stub, monkeypatch): + monkeypatch.setattr(webenginesettings.spell, 'local_filename', + lambda _code: 'en-US-8-0') + config_stub.val.spellcheck.languages = ['en-US'] + webenginesettings._update_settings('spellcheck.languages') + for profile in [webenginesettings.default_profile, + webenginesettings.private_profile]: + assert profile.isSpellCheckEnabled() + assert profile.spellCheckLanguages() == ['en-US-8-0']