From 19ac4889977edda6b2b2e87d2940b355ed39176e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 5 Sep 2016 12:31:29 +0200 Subject: [PATCH] tests: Add QUTE_BDD_WEBENGINE environment variable --- tests/conftest.py | 6 ++++++ tests/end2end/conftest.py | 8 ++++---- tests/end2end/features/conftest.py | 8 ++++---- tests/end2end/features/test_marks_bdd.py | 2 +- tests/end2end/fixtures/quteprocess.py | 5 ++--- tests/end2end/test_hints_html.py | 11 +++++------ tests/end2end/test_insert_mode.py | 2 +- 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 4e5e19738..aac0e2014 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -138,6 +138,12 @@ def pytest_addoption(parser): help='Use QtWebEngine for BDD tests') +def pytest_configure(config): + webengine_arg = config.getoption('--qute-bdd-webengine') + webengine_env = os.environ.get('QUTE_BDD_WEBENGINE', '') + config.webengine = bool(webengine_arg or webengine_env) + + @pytest.fixture(scope='session', autouse=True) def check_display(request): if (not request.config.getoption('--no-xvfb') and diff --git a/tests/end2end/conftest.py b/tests/end2end/conftest.py index a8a40d824..79bcb5e0b 100644 --- a/tests/end2end/conftest.py +++ b/tests/end2end/conftest.py @@ -131,18 +131,18 @@ if not getattr(sys, 'frozen', False): def pytest_collection_modifyitems(config, items): """Apply @qtwebengine_* markers.""" - webengine = config.getoption('--qute-bdd-webengine') vercheck = qtutils.version_check qtbug_54419_fixed = ((vercheck('5.6.2') and not vercheck('5.7.0')) or qtutils.version_check('5.7.1') or os.environ.get('QUTE_QTBUG54419_PATCHED', '')) markers = { - 'qtwebengine_todo': ('QtWebEngine TODO', pytest.mark.xfail, webengine), + 'qtwebengine_todo': ('QtWebEngine TODO', pytest.mark.xfail, + config.webengine), 'qtwebengine_skip': ('Skipped with QtWebEngine', pytest.mark.skipif, - webengine), + config.webengine), 'qtwebkit_skip': ('Skipped with QtWebKit', pytest.mark.skipif, - not webengine), + not config.webengine), 'qtwebengine_createWindow': ('Skipped because of QTBUG-54419', pytest.mark.skipif, not qtbug_54419_fixed) } diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index c350753b5..e911b14a5 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -408,7 +408,7 @@ def compare_session(request, quteproc, expected): partial_compare is used, which means only the keys/values listed will be compared. """ - if request.config.getoption('--qute-bdd-webengine'): + if request.config.webengine: pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented") quteproc.compare_session(expected) @@ -473,7 +473,7 @@ def check_open_tabs(quteproc, request, tabs): It expects a list of URLs, with an optional "(active)" suffix. """ - if request.config.getoption('--qute-bdd-webengine'): + if request.config.webengine: pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented") session = quteproc.get_session() active_suffix = ' (active)' @@ -530,7 +530,7 @@ def _get_scroll_values(quteproc): @bdd.then(bdd.parsers.re(r"the page should be scrolled " r"(?Phorizontally|vertically)")) def check_scrolled(request, quteproc, direction): - if request.config.getoption('--qute-bdd-webengine'): + if request.config.webengine: pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented") x, y = _get_scroll_values(quteproc) if direction == 'horizontally': @@ -543,7 +543,7 @@ def check_scrolled(request, quteproc, direction): @bdd.then("the page should not be scrolled") def check_not_scrolled(request, quteproc): - if request.config.getoption('--qute-bdd-webengine'): + if request.config.webengine: pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented") x, y = _get_scroll_values(quteproc) assert x == 0 diff --git a/tests/end2end/features/test_marks_bdd.py b/tests/end2end/features/test_marks_bdd.py index 858456996..58aec5a00 100644 --- a/tests/end2end/features/test_marks_bdd.py +++ b/tests/end2end/features/test_marks_bdd.py @@ -24,7 +24,7 @@ bdd.scenarios('marks.feature') @bdd.then(bdd.parsers.parse("the page should be scrolled to {x} {y}")) def check_y(request, quteproc, x, y): - if request.config.getoption('--qute-bdd-webengine'): + if request.config.webengine: pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented") data = quteproc.get_session() pos = data['windows'][0]['tabs'][0]['history'][-1]['scroll-pos'] diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 5b621af47..778ae732f 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -157,7 +157,6 @@ class QuteProc(testprocess.Process): def __init__(self, request, *, parent=None): super().__init__(parent) - self._webengine = request.config.getoption('--qute-bdd-webengine') self._ipc_socket = None self.basedir = None self._focus_ready = False @@ -261,7 +260,7 @@ class QuteProc(testprocess.Process): return executable, args def _default_args(self): - backend = 'webengine' if self._webengine else 'webkit' + backend = 'webengine' if self.request.config.webengine else 'webkit' return ['--debug', '--no-err-windows', '--temp-basedir', '--json-logging', '--backend', backend, 'about:blank'] @@ -338,7 +337,7 @@ class QuteProc(testprocess.Process): ('general', 'auto-save-interval', '0'), ('general', 'new-instance-open-target.window', 'last-opened') ] - if not self._webengine: + if not self.request.config.webengine: settings.append(('network', 'ssl-strict', 'false')) for sect, opt, value in settings: diff --git a/tests/end2end/test_hints_html.py b/tests/end2end/test_hints_html.py index 406e1bd46..c2d5143bc 100644 --- a/tests/end2end/test_hints_html.py +++ b/tests/end2end/test_hints_html.py @@ -85,21 +85,20 @@ def _parse_file(test_name): @pytest.mark.parametrize('find_implementation', ['javascript', 'python']) def test_hints(test_name, zoom_text_only, zoom_level, find_implementation, quteproc, request): - webengine = bool(request.config.getoption('--qute-bdd-webengine')) - if zoom_text_only and webengine: + if zoom_text_only and request.config.webengine: pytest.skip("QtWebEngine doesn't have zoom-text-only") - if find_implementation == 'python' and webengine: + if find_implementation == 'python' and request.config.webengine: pytest.skip("QtWebEngine doesn't have a python find implementation") parsed = _parse_file(test_name) - if parsed.qtwebengine_todo is not None and webengine: + if parsed.qtwebengine_todo is not None and request.config.webengine: pytest.xfail("QtWebEngine TODO: {}".format(parsed.qtwebengine_todo)) url_path = 'data/hints/html/{}'.format(test_name) quteproc.open_path(url_path) # setup - if not webengine: + if not request.config.webengine: quteproc.set_setting('ui', 'zoom-text-only', str(zoom_text_only)) quteproc.set_setting('hints', 'find-implementation', find_implementation) @@ -111,7 +110,7 @@ def test_hints(test_name, zoom_text_only, zoom_level, find_implementation, quteproc.wait_for_load_finished('data/' + parsed.target) # reset quteproc.send_cmd(':zoom 100') - if not webengine: + if not request.config.webengine: quteproc.set_setting('ui', 'zoom-text-only', 'false') quteproc.set_setting('hints', 'find-implementation', 'javascript') diff --git a/tests/end2end/test_insert_mode.py b/tests/end2end/test_insert_mode.py index f8dc7a547..a3edd651e 100644 --- a/tests/end2end/test_insert_mode.py +++ b/tests/end2end/test_insert_mode.py @@ -48,7 +48,7 @@ def test_insert_mode(file_name, elem_id, source, input_text, auto_insert, if source == 'keypress': quteproc.press_keys(input_text) elif source == 'clipboard': - if request.config.getoption('--qute-bdd-webengine'): + if request.config.webengine: pytest.xfail(reason="QtWebEngine TODO: :insert-text is not " "implemented") quteproc.send_cmd(':debug-set-fake-clipboard "{}"'.format(input_text))