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/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) 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..eaecf406e --- /dev/null +++ b/scripts/dev/pylint_checkers/setup.py @@ -0,0 +1,25 @@ +#!/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']) 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])) 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/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/features/conftest.py b/tests/integration/features/conftest.py index 501e1940d..03559ede7 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -212,12 +212,7 @@ 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) - 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")) 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) 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']) diff --git a/tox.ini b/tox.ini index 465c393fd..40da3f154 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 @@ -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