diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-03-25 12:51:45 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-03-25 15:41:56 +0100 |
commit | 54a0dc1e386e1507bdf9af88beab7fcf033d1f88 (patch) | |
tree | 7d0b51ccc00f9b889724527f351c026f32363eaa /tests/end2end | |
parent | 4eb653c1ed3717b66c10dd4d684ba5c8dad0d2f3 (diff) | |
download | qutebrowser-54a0dc1e386e1507bdf9af88beab7fcf033d1f88.tar.gz qutebrowser-54a0dc1e386e1507bdf9af88beab7fcf033d1f88.zip |
notifications: Replace @qtwebengine_py_5_15 by @pyqtwebengine>=5.15
Diffstat (limited to 'tests/end2end')
-rw-r--r-- | tests/end2end/conftest.py | 65 | ||||
-rw-r--r-- | tests/end2end/features/notifications.feature | 11 |
2 files changed, 47 insertions, 29 deletions
diff --git a/tests/end2end/conftest.py b/tests/end2end/conftest.py index b903c96d9..a4a089cea 100644 --- a/tests/end2end/conftest.py +++ b/tests/end2end/conftest.py @@ -61,6 +61,21 @@ def pytest_unconfigure(config): stats.dump_stats((pathlib.Path('prof') / 'combined.pstats')) +def _check_hex_version(op_str, running_version, version): + operators = { + '==': operator.eq, + '!=': operator.ne, + '>=': operator.ge, + '<=': operator.le, + '>': operator.gt, + '<': operator.lt, + } + op = operators[op_str] + major, minor, patch = [int(e) for e in version.split('.')] + hex_version = (major << 16) | (minor << 8) | patch + return op(running_version, hex_version) + + def _get_version_tag(tag): """Handle tags like pyqt>=5.3.1 for BDD tests. @@ -69,7 +84,7 @@ def _get_version_tag(tag): casesinto an appropriate @pytest.mark.skip marker, and falls back to """ version_re = re.compile(r""" - (?P<package>qt|pyqt) + (?P<package>qt|pyqt|pyqtwebengine) (?P<operator>==|>=|!=|<) (?P<version>\d+\.\d+(\.\d+)?) """, re.VERBOSE) @@ -92,18 +107,31 @@ def _get_version_tag(tag): } return pytest.mark.skipif(do_skip[op], reason='Needs ' + tag) elif package == 'pyqt': - operators = { - '==': operator.eq, - '>=': operator.ge, - '!=': operator.ne, - } - op = operators[match.group('operator')] - major, minor, patch = [int(e) for e in version.split('.')] - hex_version = (major << 16) | (minor << 8) | patch - return pytest.mark.skipif(not op(PYQT_VERSION, hex_version), - reason='Needs ' + tag) + return pytest.mark.skipif( + not _check_hex_version( + op_str=match.group('operator'), + running_version=PYQT_VERSION, + version=version + ), + reason='Needs ' + tag, + ) + elif package == 'pyqtwebengine': + try: + from PyQt5.QtWebEngine import PYQT_WEBENGINE_VERSION + except ImportError: + running_version = PYQT_VERSION + else: + running_version = PYQT_WEBENGINE_VERSION + return pytest.mark.skipif( + not _check_hex_version( + op_str=match.group('operator'), + running_version=running_version, + version=version + ), + reason='Needs ' + tag, + ) else: - raise ValueError("Invalid package {!r}".format(package)) + raise utils.Unreachable(package) def _get_backend_tag(tag): @@ -112,7 +140,6 @@ def _get_backend_tag(tag): 'qtwebengine_todo': pytest.mark.qtwebengine_todo, 'qtwebengine_skip': pytest.mark.qtwebengine_skip, 'qtwebengine_notifications': pytest.mark.qtwebengine_notifications, - 'qtwebengine_py_5_15': pytest.mark.qtwebengine_py_5_15, 'qtwebkit_skip': pytest.mark.qtwebkit_skip, } if not any(tag.startswith(t + ':') for t in pytest_marks): @@ -137,14 +164,6 @@ if not getattr(sys, 'frozen', False): return None -def _pyqt_webengine_at_least_5_15() -> bool: - try: - from PyQt5.QtWebEngine import PYQT_WEBENGINE_VERSION - return PYQT_WEBENGINE_VERSION >= 0x050F00 - except ImportError: - return False - - def pytest_collection_modifyitems(config, items): """Apply @qtwebengine_* markers; skip unittests with QUTE_BDD_WEBENGINE.""" # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-75884 @@ -180,10 +199,6 @@ def pytest_collection_modifyitems(config, items): 'Skipped on Windows', pytest.mark.skipif, utils.is_windows), - # WORKAROUND for https://www.riverbankcomputing.com/pipermail/pyqt/2020-May/042918.html - ('qtwebengine_py_5_15', 'Skipped with PyQtWebEngine < 5.15', - pytest.mark.skipif, - config.webengine and not _pyqt_webengine_at_least_5_15()), ] for item in items: diff --git a/tests/end2end/features/notifications.feature b/tests/end2end/features/notifications.feature index b37a7614b..dd3335350 100644 --- a/tests/end2end/features/notifications.feature +++ b/tests/end2end/features/notifications.feature @@ -43,28 +43,31 @@ Feature: Notifications # we try to close it, otherwise we wind up in race-condition-ish # situations. - @qtwebengine_notifications @qtwebengine_py_5_15 + # As a WORKAROUND for https://www.riverbankcomputing.com/pipermail/pyqt/2020-May/042918.html + # and other issues, those can only run with PyQtWebEngine >= 5.15.0 + + @qtwebengine_notifications @pyqtwebengine>=5.15.0 Scenario: User closes presented notification When I run :click-element id show-button And I wait for the javascript message "notification shown" And I close the notification with id 1 Then the javascript message "notification closed" should be logged - @qtwebengine_notifications @qtwebengine_py_5_15 + @qtwebengine_notifications @pyqtwebengine>=5.15.0 Scenario: User closes some other application's notification When I run :click-element id show-button And I wait for the javascript message "notification shown" And I close the notification with id 1234 Then the javascript message "notification closed" should not be logged - @qtwebengine_notifications @qtwebengine_py_5_15 + @qtwebengine_notifications @pyqtwebengine>=5.15.0 Scenario: User clicks presented notification When I run :click-element id show-button And I wait for the javascript message "notification shown" And I click the notification with id 1 Then the javascript message "notification clicked" should be logged - @qtwebengine_notifications @qtwebengine_py_5_15 + @qtwebengine_notifications @pyqtwebengine>=5.15.0 Scenario: User clicks some other application's notification When I run :click-element id show-button And I wait for the javascript message "notification shown" |