From 53719366e0c725e80e859108b29f385ca46a45c0 Mon Sep 17 00:00:00 2001 From: avk Date: Fri, 12 Feb 2016 11:02:08 +0100 Subject: [PATCH 01/22] Added time to standard log --- qutebrowser/utils/log.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index 9023085cf..bacefa2b8 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -51,10 +51,10 @@ else: colorama.deinit() # Log formats to use. -SIMPLE_FMT = '{levelname}: {message}' +SIMPLE_FMT = '{asctime:8} {levelname}: {message}' EXTENDED_FMT = ('{asctime:8} {levelname:8} {name:10} {module}:{funcName}:' '{lineno} {message}') -SIMPLE_FMT_COLORED = '%(log_color)s%(levelname)s%(reset)s: %(message)s' +SIMPLE_FMT_COLORED = '%(green)s%(asctime)-8s%(reset)s %(log_color)s%(levelname)s%(reset)s: %(message)s' EXTENDED_FMT_COLORED = ( '%(green)s%(asctime)-8s%(reset)s ' '%(log_color)s%(levelname)-8s%(reset)s ' From d551591b42794414a6f1e99e615ebdbf6b86eba1 Mon Sep 17 00:00:00 2001 From: avk Date: Fri, 12 Feb 2016 11:59:45 +0100 Subject: [PATCH 02/22] Added crash time to crash report --- qutebrowser/misc/crashdialog.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py index 4a2244af4..6dc0c5642 100644 --- a/qutebrowser/misc/crashdialog.py +++ b/qutebrowser/misc/crashdialog.py @@ -26,6 +26,7 @@ import html import getpass import fnmatch import traceback +import datetime import pkg_resources from PyQt5.QtCore import pyqtSlot, Qt, QSize, qVersion @@ -239,6 +240,10 @@ class _CrashDialog(QDialog): self._crash_info.append(('Launch time', launch_time)) except Exception: self._crash_info.append(("Launch time", traceback.format_exc())) + try: + self._crash_info.append(("Crash time", datetime.datetime.now().ctime())) + except Exception: + self._crash_info.append(("Crash time", traceback.format_exc())) try: self._crash_info.append(("Version info", version.version())) except Exception: From 60c2b9c0b20a051cddf0cdd3bf0e40603dfe6bb9 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Mon, 15 Feb 2016 21:59:09 +0100 Subject: [PATCH 03/22] fixes #1308 --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 6b9c1feca..2bfa30603 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -425,7 +425,7 @@ def pytest_configure(config): try: disp = xvfbwrapper.Xvfb(width=800, height=600, colordepth=16) disp.start() - except FileNotFoundError: + except EnvironmentError: # We run without Xvfb if it's unavailable. pass else: From 9a18bc4cedec7b33626dcf75faf862caab22f087 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 15 Feb 2016 22:08:42 +0100 Subject: [PATCH 04/22] Regenerate authors. --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 3d7c4a276..a4632f27e 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -148,8 +148,8 @@ Contributors, sorted by the number of commits in descending order: * Alexander Cogneau * Martin Tournoij * Raphael Pierzina -* Joel Torstensson * Felix Van der Jeugt +* Joel Torstensson * Claude * Patric Schmitz * meles5 From c52e93e2960cab13fa6512b15f2158f160a793c7 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Mon, 15 Feb 2016 22:52:28 +0100 Subject: [PATCH 05/22] no ellipsis is inserted in big windows --- tests/unit/mainwindow/statusbar/test_textbase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/mainwindow/statusbar/test_textbase.py b/tests/unit/mainwindow/statusbar/test_textbase.py index c33b11b0b..2b9bd4cc1 100644 --- a/tests/unit/mainwindow/statusbar/test_textbase.py +++ b/tests/unit/mainwindow/statusbar/test_textbase.py @@ -46,7 +46,7 @@ def test_elided_text(qtbot, elidemode, check): """ label = TextBase(elidemode=elidemode) qtbot.add_widget(label) - long_string = 'Hello world! ' * 20 + long_string = 'Hello world! ' * 100 label.setText(long_string) label.resize(100, 50) label.show() From 5c617b861c2a517168c694519379982db666e971 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 16 Feb 2016 20:36:23 +0100 Subject: [PATCH 06/22] Switch to pytest-xvfb. Fixes #1309. --- pytest.ini | 2 +- tests/conftest.py | 38 ++++----------------- tests/integration/features/keyinput.feature | 2 +- tests/integration/features/misc.feature | 6 ++-- tox.ini | 2 +- 5 files changed, 12 insertions(+), 38 deletions(-) diff --git a/pytest.ini b/pytest.ini index b754af883..04ebb49c0 100644 --- a/pytest.ini +++ b/pytest.ini @@ -9,7 +9,7 @@ markers = osx: Tests which only can run on OS X. not_osx: Tests which can not run on OS X. not_frozen: Tests which can't be run if sys.frozen is True. - not_xvfb: Tests which can't be run with Xvfb. + no_xvfb: Tests which can't be run with Xvfb. frozen: Tests which can only be run if sys.frozen is True. integration: Tests which test a bigger portion of code, run without coverage. skip: Always skipped test. diff --git a/tests/conftest.py b/tests/conftest.py index ed617b854..1a38d0825 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,7 +34,6 @@ from helpers.messagemock import message_mock from helpers.fixtures import * # pylint: disable=wildcard-import from PyQt5.QtCore import PYQT_VERSION -import xvfbwrapper # Set hypothesis settings @@ -55,8 +54,6 @@ def _apply_platform_markers(item): "Can't be run when frozen"), ('frozen', not getattr(sys, 'frozen', False), "Can only run when frozen"), - ('not_xvfb', item.config.xvfb_display is not None, - "Can't be run with Xvfb."), ('skip', True, "Always skipped."), ('pyqt531_or_newer', PYQT_VERSION < 0x050301, "Needs PyQt 5.3.1 or newer"), @@ -147,41 +144,18 @@ def fail_tests_on_warnings(): def pytest_addoption(parser): - parser.addoption('--no-xvfb', action='store_true', default=False, - help='Disable xvfb in tests.') parser.addoption('--qute-delay', action='store', default=0, type=int, help="Delay between qutebrowser commands.") parser.addoption('--qute-profile-subprocs', action='store_true', default=False, help="Run cProfile for subprocesses.") -def pytest_configure(config): - """Start Xvfb if we're on Linux, not on a CI and Xvfb is available. - - This is a lot nicer than having windows popping up. - """ - config.xvfb_display = None - if os.environ.get('DISPLAY', None) == '': - # xvfbwrapper doesn't handle DISPLAY="" correctly - del os.environ['DISPLAY'] - - if (sys.platform.startswith('linux') and - not config.getoption('--no-xvfb') and - 'QUTE_NO_DISPLAY' not in os.environ): - assert 'QUTE_BUILDBOT' not in os.environ - try: - disp = xvfbwrapper.Xvfb(width=800, height=600, colordepth=16) - disp.start() - except EnvironmentError: - # We run without Xvfb if it's unavailable. - pass - else: - config.xvfb_display = disp - - -def pytest_unconfigure(config): - if config.xvfb_display is not None: - config.xvfb_display.stop() +@pytest.fixture(scope='session', autouse=True) +def prevent_xvfb_on_buildbot(request): + if (not request.config.getoption('--no-xvfb') and + 'QUTE_BUILDBOT' in os.environ and + request.config.xvfb is not None): + raise Exception("Xvfb is running on buildbot!") @pytest.hookimpl(tryfirst=True, hookwrapper=True) diff --git a/tests/integration/features/keyinput.feature b/tests/integration/features/keyinput.feature index eae967874..1d930da24 100644 --- a/tests/integration/features/keyinput.feature +++ b/tests/integration/features/keyinput.feature @@ -113,7 +113,7 @@ Feature: Keyboard input Then the javascript message "key press: 88" should be logged And the javascript message "key release: 88" should be logged - @not_xvfb @posix + @no_xvfb @posix Scenario: :fake-key sending key to the website with other window focused When I open data/keyinput/log.html And I set general -> developer-extras to true diff --git a/tests/integration/features/misc.feature b/tests/integration/features/misc.feature index 38a77d6e6..7a0f9ae2f 100644 --- a/tests/integration/features/misc.feature +++ b/tests/integration/features/misc.feature @@ -108,7 +108,7 @@ Feature: Various utility commands. And I run :inspector Then the error "Please enable developer-extras before using the webinspector!" should be shown - @not_xvfb @posix + @no_xvfb @posix Scenario: Inspector smoke test When I set general -> developer-extras to true And I run :inspector @@ -124,7 +124,7 @@ Feature: Various utility commands. Then the error "Please enable developer-extras before using the webinspector!" should be shown # Different code path as an inspector got created now - @not_xvfb @posix + @no_xvfb @posix Scenario: Inspector smoke test 2 When I set general -> developer-extras to true And I run :inspector @@ -202,7 +202,7 @@ Feature: Various utility commands. # :debug-console - @not_xvfb + @no_xvfb Scenario: :debug-console smoke test When I run :debug-console And I wait for "Focus object changed: " in the log diff --git a/tox.ini b/tox.ini index b64bc9815..465c393fd 100644 --- a/tox.ini +++ b/tox.ini @@ -38,12 +38,12 @@ deps = pytest-travis-fold==1.2.0 pytest-repeat==0.2 pytest-rerunfailures==1.0.1 + pytest-xvfb==0.1.0 six==1.10.0 termcolor==1.1.0 vulture==0.8.1 Werkzeug==0.11.4 wheel==0.29.0 - xvfbwrapper==0.2.8 cherrypy==5.0.1 commands = {envpython} scripts/link_pyqt.py --tox {envdir} From 36019c0cab661021e1c6c60807256dfc40541854 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 Feb 2016 07:04:25 +0100 Subject: [PATCH 07/22] Split long lines. --- qutebrowser/misc/crashdialog.py | 3 ++- qutebrowser/utils/log.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py index 6dc0c5642..0e794b308 100644 --- a/qutebrowser/misc/crashdialog.py +++ b/qutebrowser/misc/crashdialog.py @@ -241,7 +241,8 @@ class _CrashDialog(QDialog): except Exception: self._crash_info.append(("Launch time", traceback.format_exc())) try: - self._crash_info.append(("Crash time", datetime.datetime.now().ctime())) + self._crash_info.append(("Crash time", + datetime.datetime.now().ctime())) except Exception: self._crash_info.append(("Crash time", traceback.format_exc())) try: diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index bacefa2b8..5047a2f61 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -54,7 +54,8 @@ else: SIMPLE_FMT = '{asctime:8} {levelname}: {message}' EXTENDED_FMT = ('{asctime:8} {levelname:8} {name:10} {module}:{funcName}:' '{lineno} {message}') -SIMPLE_FMT_COLORED = '%(green)s%(asctime)-8s%(reset)s %(log_color)s%(levelname)s%(reset)s: %(message)s' +SIMPLE_FMT_COLORED = ('%(green)s%(asctime)-8s%(reset)s ' + '%(log_color)s%(levelname)s%(reset)s: %(message)s') EXTENDED_FMT_COLORED = ( '%(green)s%(asctime)-8s%(reset)s ' '%(log_color)s%(levelname)-8s%(reset)s ' From 2b2331754df40dd8d730ee72897bbfa61d5544c5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 Feb 2016 07:10:01 +0100 Subject: [PATCH 08/22] Combine launch/crash time into one section. --- qutebrowser/misc/crashdialog.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py index 0e794b308..213c38187 100644 --- a/qutebrowser/misc/crashdialog.py +++ b/qutebrowser/misc/crashdialog.py @@ -237,14 +237,11 @@ class _CrashDialog(QDialog): try: application = QApplication.instance() launch_time = application.launch_time.ctime() - self._crash_info.append(('Launch time', launch_time)) + crash_time = datetime.datetime.now().ctime() + text = 'Launch: {}\nCrash: {}'.format(launch_time, crash_time) + self._crash_info.append(('Timestamps', text)) except Exception: self._crash_info.append(("Launch time", traceback.format_exc())) - try: - self._crash_info.append(("Crash time", - datetime.datetime.now().ctime())) - except Exception: - self._crash_info.append(("Crash time", traceback.format_exc())) try: self._crash_info.append(("Version info", version.version())) except Exception: From 7ba6752020aa2341e515172ec0df97c9ef42115e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 Feb 2016 07:10:14 +0100 Subject: [PATCH 09/22] Regenerate authors. --- README.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/README.asciidoc b/README.asciidoc index a4632f27e..de1fefdaa 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -184,6 +184,7 @@ Contributors, sorted by the number of commits in descending order: * Link * Larry Hynes * Johannes Altmanninger +* avk * Samir Benmendil * Regina Hug * Mathias Fussenegger From 504bf6eb3bfb2ea9c380883f18c5430b7d71b883 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 Feb 2016 07:45:36 +0100 Subject: [PATCH 10/22] Remove xvfbwrapper from freeze_tests.py. --- scripts/dev/freeze_tests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/dev/freeze_tests.py b/scripts/dev/freeze_tests.py index 524dc1999..580033aae 100755 --- a/scripts/dev/freeze_tests.py +++ b/scripts/dev/freeze_tests.py @@ -55,8 +55,7 @@ def get_build_exe_options(): opts = freeze.get_build_exe_options(skip_html=True) opts['includes'] += pytest.freeze_includes() # pylint: disable=no-member opts['includes'] += ['unittest.mock', 'PyQt5.QtTest', 'hypothesis', 'bs4', - 'httpbin', 'jinja2.ext', 'xvfbwrapper', - 'cherrypy.wsgiserver', + 'httpbin', 'jinja2.ext', 'cherrypy.wsgiserver', 'cherrypy.wsgiserver.wsgiserver3', 'pstats'] httpbin_dir = os.path.dirname(httpbin.__file__) From 9a02dc174d5283fee9aefb9a6ffdabf605cfb014 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Feb 2016 07:34:35 +0100 Subject: [PATCH 11/22] bdd: use quteproc.wait_for_load_finished. Why duplicate that logic? --- tests/integration/features/conftest.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 501e1940d..9c47d1337 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -213,11 +213,7 @@ def path_should_be_loaded(quteproc, path): page could be loaded from local cache. """ url = quteproc.path_to_url(path) - pattern = re.compile( - r"load status for : LoadStatus\.success".format( - url=re.escape(url))) - quteproc.wait_for(message=pattern) + quteproc.wait_for_load_finished(path) @bdd.then(bdd.parsers.parse("{path} should be requested")) From 9b1db7ec0bfe37e63d54848ac93fa230d73e111b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Feb 2016 07:34:51 +0100 Subject: [PATCH 12/22] hints: Log the used hint chars Useful for debugging and for end2end tests. --- qutebrowser/browser/hints.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index c9a722dc6..26fd02fbc 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -677,6 +677,7 @@ class HintManager(QObject): if not elems: raise cmdexc.CommandError("No elements found.") hints = self._hint_strings(elems) + log.hints.debug("hints: {}".format(', '.join(hints))) for e, hint in zip(elems, hints): label = self._draw_label(e, hint) self._context.elems[hint] = ElemTuple(e, label) From 36b0e304fc46cd6821be1804bc8f9fae280b9cef Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Feb 2016 07:35:14 +0100 Subject: [PATCH 13/22] tests: Add first end-to-end test for hints. This is based on HTML files with a global YAML comment, currently with "target" as the only allowed key. The tests then do this: - Open a HTML file in data/hints/html - Start hinting - Make sure only one hint is visible - Follow it, and make sure the page mentioned in "target:" is reached Some ideas for the future: - A "scroll" key, to scroll before hinting - A "zoom" key, to zoom - Multiple hints via a list - Checking position of hints? - A mode to manually check the pages (to check hint positions) --- tests/integration/data/hints/html/simple.html | 13 +++++ tests/integration/test_hints_html.py | 56 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/integration/data/hints/html/simple.html create mode 100644 tests/integration/test_hints_html.py diff --git a/tests/integration/data/hints/html/simple.html b/tests/integration/data/hints/html/simple.html new file mode 100644 index 000000000..40e908a13 --- /dev/null +++ b/tests/integration/data/hints/html/simple.html @@ -0,0 +1,13 @@ + + + + + + + + Simple link + + + Follow me! + + diff --git a/tests/integration/test_hints_html.py b/tests/integration/test_hints_html.py new file mode 100644 index 000000000..cc668193d --- /dev/null +++ b/tests/integration/test_hints_html.py @@ -0,0 +1,56 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2016 Florian Bruhin (The Compiler) +# +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + +"""Test hints based on html files with special comments.""" + +import os +import os.path + +import yaml +import pytest +import bs4 + + +def collect_tests(): + basedir = os.path.dirname(__file__) + datadir = os.path.join(basedir, 'data', 'hints', 'html') + files = os.listdir(datadir) + return files + + +@pytest.mark.parametrize('test_name', collect_tests()) +def test_hints(test_name, quteproc): + file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), + 'data', 'hints', 'html', test_name) + url_path = 'data/hints/html/{}'.format(test_name) + quteproc.open_path(url_path) + quteproc.wait_for_load_finished(url_path) + + with open(file_path, 'r', encoding='utf-8') as html: + soup = bs4.BeautifulSoup(html, 'html.parser') + + comment = soup.find(text=lambda text: isinstance(text, bs4.Comment)) + parsed = yaml.load(comment) + + assert set(parsed.keys()) == {'target'} + + quteproc.send_cmd(':hint links normal') + quteproc.wait_for(message='hints: a', category='hints') + quteproc.send_cmd(':follow-hint a') + quteproc.wait_for_load_finished('data/' + parsed['target']) From 0c4a961505b6ef9906c78ced8ee49984053344a3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Feb 2016 20:33:14 +0100 Subject: [PATCH 14/22] tox: Upgrade hypothesis to 3.0.2. (3.0.2: performance fix) ------------------ 3.0.1 - 2016-02-18 ------------------ * Fix a case where it was possible to trigger an "Unreachable" assertion when running certain flaky stateful tests. * Improve shrinking of large stateful tests by eliminating a case where it was hard to delete early steps. * Improve efficiency of drawing binary(min_size=n, max_size=n) significantly by provide a custom implementation for fixed size blocks that can bypass a lot of machinery. * Set default home directory based on the current working directory at the point Hypothesis is imported, not whenever the function first happens to be called. ------------------ 3.0.0 - 2016-02-17 ------------------ Codename: This really should have been 2.1. Externally this looks like a very small release. It has one small breaking change that probably doesn't affect anyone at all (some behaviour that never really worked correctly is now outright forbidden) but necessitated a major version bump and one visible new feature. Internally this is a complete rewrite. Almost nothing other than the public API is the same. New features: * Addition of data() strategy which allows you to draw arbitrary data interactively within the test. * New "exploded" database format which allows you to more easily check the example database into a source repository while supporting merging. * Better management of how examples are saved in the database. * Health checks will now raise as errors when they fail. It was too easy to have the warnings be swallowed entirely. New limitations: * choices and streaming strategies may no longer be used with find(). Neither may data() (this is the change that necessitated a major version bump). Feature removal: * The ForkingTestCase executor has gone away. It may return in some more working form at a later date. Performance improvements: * A new model which allows flatmap, composite strategies and stateful testing to perform *much* better. They should also be more reliable. * Filtering may in some circumstances have improved significantly. This will help especially in cases where you have lots of values with individual filters on them, such as lists(x.filter(...)). * Modest performance improvements to the general test runner by avoiding expensive operations In general your tests should have got faster. If they've instead got significantly slower, I'm interested in hearing about it. Data distribution: The data distribution should have changed significantly. This may uncover bugs the previous version missed. It may also miss bugs the previous version could have uncovered. Hypothesis is now producing less strongly correlated data than it used to, but the correlations are extended over more of the structure. Shrinking: Shrinking quality should have improved. In particular Hypothesis can now perform simultaneous shrinking of separate examples within a single test (previously it was only able to do this for elements of a single collection). In some cases performance will have improved, in some cases it will have got worse but generally shouldn't have by much. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 465c393fd..166e877b1 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ deps = Flask==0.10.1 glob2==0.4.1 httpbin==0.4.1 - hypothesis==2.0.0 + hypothesis==3.0.2 itsdangerous==0.24 Mako==1.0.3 parse==1.6.6 From 6a077f5d5a07c56190b63f9cdae5d76a816a7261 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Feb 2016 21:38:23 +0100 Subject: [PATCH 15/22] Fix lint. --- tests/integration/features/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 9c47d1337..03559ede7 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -212,7 +212,6 @@ def path_should_be_loaded(quteproc, path): This is usally the better check compared to "should be requested" as the page could be loaded from local cache. """ - url = quteproc.path_to_url(path) quteproc.wait_for_load_finished(path) From b201b65669fe3d69d4a933ec1e22aae625644f74 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 19 Feb 2016 06:42:23 +0100 Subject: [PATCH 16/22] tests: Handle trailing / in wait_for_load_finished. We actually already added that in 16ec0354188abee95fb55504d83815b916e61d52, but in 9a02dc174d5283fee9aefb9a6ffdabf605cfb014 we accidentally dropped it again. --- tests/integration/quteprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/quteprocess.py b/tests/integration/quteprocess.py index 21f811193..5b9fb3281 100644 --- a/tests/integration/quteprocess.py +++ b/tests/integration/quteprocess.py @@ -380,7 +380,7 @@ class QuteProc(testprocess.Process): url = utils.elide(QUrl(url).toDisplayString(QUrl.EncodeUnicode), 100) pattern = re.compile( r"(load status for : LoadStatus\.{load_status}|fetch: " + r"tab_id=\d+ url='{url}/?'>: LoadStatus\.{load_status}|fetch: " r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format( load_status=re.escape(load_status), url=re.escape(url))) self.wait_for(message=pattern, timeout=timeout) From 67b99047726668cb3479914d9a8fb9ce68cc35f8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 19 Feb 2016 06:52:19 +0100 Subject: [PATCH 17/22] Include pytest-xvfb properly in frozen tests --- scripts/dev/run_frozen_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/dev/run_frozen_tests.py b/scripts/dev/run_frozen_tests.py index 09782109b..ab933f595 100644 --- a/scripts/dev/run_frozen_tests.py +++ b/scripts/dev/run_frozen_tests.py @@ -28,7 +28,8 @@ import pytest_mock import pytest_catchlog import pytest_instafail import pytest_faulthandler +import pytest_xvfb sys.exit(pytest.main(plugins=[pytestqt.plugin, pytest_mock, pytest_catchlog, pytest_instafail, - pytest_faulthandler])) + pytest_faulthandler, pytest_xvfb])) From 0b362e76eac75f9e35f6501d3fbaa13cfedd4b78 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 19 Feb 2016 07:09:13 +0100 Subject: [PATCH 18/22] Move pylint plugins to an installed package. This means we can now run things like running pylint --version without having to set PYTHONPATH correctly now. When using skip_install=true, the plugins wouldn't work as they need to import qutebrowser. We have to keep setting PYTHONPATH in run_pylint_on_tests.py, otherwise we get this error I don't quite understand: F: 1, 0: error while code parsing: Unable to load file '/home/florian/proj/qutebrowser/git/__init__.py' ([Errno 2] No such file or directory: '...') (parse-error) --- .pylintrc | 8 ++++---- scripts/dev/pylint_checkers/{ => qute_pylint}/__init__.py | 0 scripts/dev/pylint_checkers/{ => qute_pylint}/config.py | 0 scripts/dev/pylint_checkers/{ => qute_pylint}/modeline.py | 0 .../dev/pylint_checkers/{ => qute_pylint}/openencoding.py | 0 scripts/dev/pylint_checkers/{ => qute_pylint}/settrace.py | 0 scripts/dev/pylint_checkers/setup.py | 4 ++++ scripts/dev/run_pylint_on_tests.py | 2 +- tox.ini | 6 ++---- 9 files changed, 11 insertions(+), 9 deletions(-) rename scripts/dev/pylint_checkers/{ => qute_pylint}/__init__.py (100%) rename scripts/dev/pylint_checkers/{ => qute_pylint}/config.py (100%) rename scripts/dev/pylint_checkers/{ => qute_pylint}/modeline.py (100%) rename scripts/dev/pylint_checkers/{ => qute_pylint}/openencoding.py (100%) rename scripts/dev/pylint_checkers/{ => qute_pylint}/settrace.py (100%) create mode 100644 scripts/dev/pylint_checkers/setup.py diff --git a/.pylintrc b/.pylintrc index d70a59273..4c64f485e 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,10 +3,10 @@ [MASTER] ignore=resources.py extension-pkg-whitelist=PyQt5,sip -load-plugins=pylint_checkers.config, - pylint_checkers.modeline, - pylint_checkers.openencoding, - pylint_checkers.settrace +load-plugins=qute_pylint.config, + qute_pylint.modeline, + qute_pylint.openencoding, + qute_pylint.settrace [MESSAGES CONTROL] enable=all diff --git a/scripts/dev/pylint_checkers/__init__.py b/scripts/dev/pylint_checkers/qute_pylint/__init__.py similarity index 100% rename from scripts/dev/pylint_checkers/__init__.py rename to scripts/dev/pylint_checkers/qute_pylint/__init__.py diff --git a/scripts/dev/pylint_checkers/config.py b/scripts/dev/pylint_checkers/qute_pylint/config.py similarity index 100% rename from scripts/dev/pylint_checkers/config.py rename to scripts/dev/pylint_checkers/qute_pylint/config.py diff --git a/scripts/dev/pylint_checkers/modeline.py b/scripts/dev/pylint_checkers/qute_pylint/modeline.py similarity index 100% rename from scripts/dev/pylint_checkers/modeline.py rename to scripts/dev/pylint_checkers/qute_pylint/modeline.py diff --git a/scripts/dev/pylint_checkers/openencoding.py b/scripts/dev/pylint_checkers/qute_pylint/openencoding.py similarity index 100% rename from scripts/dev/pylint_checkers/openencoding.py rename to scripts/dev/pylint_checkers/qute_pylint/openencoding.py diff --git a/scripts/dev/pylint_checkers/settrace.py b/scripts/dev/pylint_checkers/qute_pylint/settrace.py similarity index 100% rename from scripts/dev/pylint_checkers/settrace.py rename to scripts/dev/pylint_checkers/qute_pylint/settrace.py diff --git a/scripts/dev/pylint_checkers/setup.py b/scripts/dev/pylint_checkers/setup.py new file mode 100644 index 000000000..b1a4ede88 --- /dev/null +++ b/scripts/dev/pylint_checkers/setup.py @@ -0,0 +1,4 @@ +# This is only here so we can install those plugins in tox.ini easily. + +from setuptools import setup +setup(name='qute_pylint', packages=['qute_pylint']) diff --git a/scripts/dev/run_pylint_on_tests.py b/scripts/dev/run_pylint_on_tests.py index cb1e9e1db..01dd14ad7 100644 --- a/scripts/dev/run_pylint_on_tests.py +++ b/scripts/dev/run_pylint_on_tests.py @@ -60,7 +60,7 @@ def main(): ] toxinidir = sys.argv[1] - pythonpath = os.environ['PYTHONPATH'].split(os.pathsep) + [ + pythonpath = os.environ.get('PYTHONPATH', '').split(os.pathsep) + [ toxinidir, ] diff --git a/tox.ini b/tox.ini index 166e877b1..40da3f154 100644 --- a/tox.ini +++ b/tox.ini @@ -122,8 +122,6 @@ commands = [testenv:pylint] basepython = python3 ignore_errors = true -skip_install = true -setenv = PYTHONPATH={toxinidir}/scripts/dev passenv = deps = {[testenv]deps} @@ -131,6 +129,7 @@ deps = astroid==1.4.4 pylint==1.5.4 requests==2.9.1 + ./scripts/dev/pylint_checkers commands = {envpython} scripts/link_pyqt.py --tox {envdir} {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no @@ -138,14 +137,13 @@ commands = [testenv:pylint-tip] basepython = python3 -skip_install = true -setenv = {[testenv:pylint]setenv} passenv = {[testenv:pylint]passenv} deps = {[testenv]deps} {[testenv:misc]deps} hg+https://bitbucket.org/logilab/astroid hg+https://bitbucket.org/logilab/pylint + ./scripts/dev/pylint_checkers commands = {envpython} scripts/link_pyqt.py --tox {envdir} {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no From d0e79b2af760475b989e96603acb00e65f9d54a2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 19 Feb 2016 07:39:17 +0100 Subject: [PATCH 19/22] Fix lint --- scripts/dev/pylint_checkers/setup.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/dev/pylint_checkers/setup.py b/scripts/dev/pylint_checkers/setup.py index b1a4ede88..eaecf406e 100644 --- a/scripts/dev/pylint_checkers/setup.py +++ b/scripts/dev/pylint_checkers/setup.py @@ -1,4 +1,25 @@ -# This is only here so we can install those plugins in tox.ini easily. +#!/usr/bin/env python3 + +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2016 Florian Bruhin (The Compiler) +# +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + +"""This is only here so we can install those plugins in tox.ini easily.""" from setuptools import setup setup(name='qute_pylint', packages=['qute_pylint']) From 513e4d5236bebb25c7938dc0d43d1282cc9ea7f7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 19 Feb 2016 18:05:51 +0100 Subject: [PATCH 20/22] Switch to flake8-docstrings with pydocstyle We used to use flake8-pep257 because docstrings claims no codes are ignorable (which is wrong). However, that doesn't work with pydocstyle, so we had a separate pydocstyle environment (and flake8-pep257 to check tests with relaxed rules). Now we only use flake8-docstrings + pydocstyle (which it switches to if it's available, even though it still depends on pep257), and drop the pydocstyle tox env. As soon as flake8-docstrings is updated to drop the (unneeded) pep257 dependency, we can drop it as well. --- .travis.yml | 3 --- tox.ini | 14 ++++---------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 658bee4c1..c72a05059 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,6 @@ env: - TESTENV=unittests-nodisp - TESTENV=misc - TESTENV=vulture - - TESTENV=pydocstyle - TESTENV=flake8 - TESTENV=pyroma - TESTENV=check-manifest @@ -52,8 +51,6 @@ matrix: env: TESTENV=misc - os: osx env: TESTENV=vulture - - os: osx - env: TESTENV=pydocstyle - os: osx env: TESTENV=flake8 - os: osx diff --git a/tox.ini b/tox.ini index 40da3f154..9166a4bc1 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py34,py35-cov,misc,vulture,pydocstyle,flake8,pylint,pyroma,check-manifest +envlist = py34,py35-cov,misc,vulture,flake8,pylint,pyroma,check-manifest [testenv] # https://bitbucket.org/hpk42/tox/issue/246/ - only needed for Windows though @@ -149,13 +149,6 @@ commands = {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no {envpython} scripts/dev/run_pylint_on_tests.py --output-format=colorized --reports=no -[testenv:pydocstyle] -basepython = python3 -skip_install = true -passenv = PYTHON LANG -deps = pydocstyle==1.0.0 -commands = {envpython} -m pydocstyle scripts tests qutebrowser - [testenv:flake8] basepython = python3 passenv = @@ -174,8 +167,9 @@ deps = flake8-deprecated==0.2 flake8-mock==0.2 flake8-pep3101==0.2 - flake8-pep257==1.0.5 - pep257==0.7.0 + flake8-docstrings==0.2.5 + pep257==0.7.0 # still needed by flake8-docstrings but ignored + pydocstyle==1.0.0 commands = {envpython} -m flake8 From f64916b516e3a3a31139e0a825d094a71183ba45 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 21 Feb 2016 17:23:10 +0100 Subject: [PATCH 21/22] Only run geolocation tests on CI Trying to get the device location while running the tests can trigger all kind of funny effects. Since we can't easily mock the GPS responses, we only run those on the CI where we at least have some predictable setup. Fixes #1297. --- pytest.ini | 1 + tests/conftest.py | 1 + tests/integration/features/prompts.feature | 2 ++ 3 files changed, 4 insertions(+) diff --git a/pytest.ini b/pytest.ini index 04ebb49c0..e52ef27d8 100644 --- a/pytest.ini +++ b/pytest.ini @@ -16,6 +16,7 @@ markers = pyqt531_or_newer: Needs PyQt 5.3.1 or newer. xfail_norun: xfail the test with out running it flaky: Tests which are flaky and should be rerun + ci: Tests which should only run on CI. qt_log_level_fail = WARNING qt_log_ignore = ^SpellCheck: .* diff --git a/tests/conftest.py b/tests/conftest.py index 1a38d0825..bdfd96510 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -57,6 +57,7 @@ def _apply_platform_markers(item): ('skip', True, "Always skipped."), ('pyqt531_or_newer', PYQT_VERSION < 0x050301, "Needs PyQt 5.3.1 or newer"), + ('ci', 'CI' not in os.environ, "Only runs on CI."), ] for searched_marker, condition, default_reason in markers: diff --git a/tests/integration/features/prompts.feature b/tests/integration/features/prompts.feature index 94059f399..b4a5091ac 100644 --- a/tests/integration/features/prompts.feature +++ b/tests/integration/features/prompts.feature @@ -122,12 +122,14 @@ Feature: Prompts And I click the button Then the javascript message "geolocation permission denied" should be logged + @ci Scenario: Always accepting geolocation When I set content -> geolocation to true And I open data/prompt/geolocation.html in a new tab And I click the button Then the javascript message "geolocation permission denied" should not be logged + @ci Scenario: geolocation with ask -> true When I set content -> geolocation to ask And I open data/prompt/geolocation.html in a new tab From 609d9b9a2552a024c057bb56dbb3e2763df42c5f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 22 Feb 2016 11:50:38 +0100 Subject: [PATCH 22/22] Regenerate authors. --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index de1fefdaa..8fdc2fb49 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -147,8 +147,8 @@ Contributors, sorted by the number of commits in descending order: * Bruno Oliveira * Alexander Cogneau * Martin Tournoij -* Raphael Pierzina * Felix Van der Jeugt +* Raphael Pierzina * Joel Torstensson * Claude * Patric Schmitz