This commit is contained in:
avk 2016-02-19 12:14:06 +01:00
commit 108f0e9073
15 changed files with 107 additions and 18 deletions

View File

@ -3,10 +3,10 @@
[MASTER] [MASTER]
ignore=resources.py ignore=resources.py
extension-pkg-whitelist=PyQt5,sip extension-pkg-whitelist=PyQt5,sip
load-plugins=pylint_checkers.config, load-plugins=qute_pylint.config,
pylint_checkers.modeline, qute_pylint.modeline,
pylint_checkers.openencoding, qute_pylint.openencoding,
pylint_checkers.settrace qute_pylint.settrace
[MESSAGES CONTROL] [MESSAGES CONTROL]
enable=all enable=all

View File

@ -677,6 +677,7 @@ class HintManager(QObject):
if not elems: if not elems:
raise cmdexc.CommandError("No elements found.") raise cmdexc.CommandError("No elements found.")
hints = self._hint_strings(elems) hints = self._hint_strings(elems)
log.hints.debug("hints: {}".format(', '.join(hints)))
for e, hint in zip(elems, hints): for e, hint in zip(elems, hints):
label = self._draw_label(e, hint) label = self._draw_label(e, hint)
self._context.elems[hint] = ElemTuple(e, label) self._context.elems[hint] = ElemTuple(e, label)

View File

@ -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) <mail@qutebrowser.org>
#
# 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 <http://www.gnu.org/licenses/>.
"""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'])

View File

@ -28,7 +28,8 @@ import pytest_mock
import pytest_catchlog import pytest_catchlog
import pytest_instafail import pytest_instafail
import pytest_faulthandler import pytest_faulthandler
import pytest_xvfb
sys.exit(pytest.main(plugins=[pytestqt.plugin, pytest_mock, sys.exit(pytest.main(plugins=[pytestqt.plugin, pytest_mock,
pytest_catchlog, pytest_instafail, pytest_catchlog, pytest_instafail,
pytest_faulthandler])) pytest_faulthandler, pytest_xvfb]))

View File

@ -60,7 +60,7 @@ def main():
] ]
toxinidir = sys.argv[1] toxinidir = sys.argv[1]
pythonpath = os.environ['PYTHONPATH'].split(os.pathsep) + [ pythonpath = os.environ.get('PYTHONPATH', '').split(os.pathsep) + [
toxinidir, toxinidir,
] ]

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<!-- target: hello.txt -->
<html>
<head>
<meta charset="utf-8">
<title>Simple link</title>
</head>
<body>
<a href="/data/hello.txt">Follow me!</a>
</body>
</html>

View File

@ -212,12 +212,7 @@ def path_should_be_loaded(quteproc, path):
This is usally the better check compared to "should be requested" as the This is usally the better check compared to "should be requested" as the
page could be loaded from local cache. page could be loaded from local cache.
""" """
url = quteproc.path_to_url(path) quteproc.wait_for_load_finished(path)
pattern = re.compile(
r"load status for <qutebrowser\.browser\.webview\.WebView "
r"tab_id=\d+ url='{url}/?'>: LoadStatus\.success".format(
url=re.escape(url)))
quteproc.wait_for(message=pattern)
@bdd.then(bdd.parsers.parse("{path} should be requested")) @bdd.then(bdd.parsers.parse("{path} should be requested"))

View File

@ -380,7 +380,7 @@ class QuteProc(testprocess.Process):
url = utils.elide(QUrl(url).toDisplayString(QUrl.EncodeUnicode), 100) url = utils.elide(QUrl(url).toDisplayString(QUrl.EncodeUnicode), 100)
pattern = re.compile( pattern = re.compile(
r"(load status for <qutebrowser\.browser\.webview\.WebView " r"(load status for <qutebrowser\.browser\.webview\.WebView "
r"tab_id=\d+ url='{url}'>: LoadStatus\.{load_status}|fetch: " r"tab_id=\d+ url='{url}/?'>: LoadStatus\.{load_status}|fetch: "
r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format( r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format(
load_status=re.escape(load_status), url=re.escape(url))) load_status=re.escape(load_status), url=re.escape(url)))
self.wait_for(message=pattern, timeout=timeout) self.wait_for(message=pattern, timeout=timeout)

View File

@ -0,0 +1,56 @@
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
#
# 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 <http://www.gnu.org/licenses/>.
"""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'])

View File

@ -20,7 +20,7 @@ deps =
Flask==0.10.1 Flask==0.10.1
glob2==0.4.1 glob2==0.4.1
httpbin==0.4.1 httpbin==0.4.1
hypothesis==2.0.0 hypothesis==3.0.2
itsdangerous==0.24 itsdangerous==0.24
Mako==1.0.3 Mako==1.0.3
parse==1.6.6 parse==1.6.6
@ -122,8 +122,6 @@ commands =
[testenv:pylint] [testenv:pylint]
basepython = python3 basepython = python3
ignore_errors = true ignore_errors = true
skip_install = true
setenv = PYTHONPATH={toxinidir}/scripts/dev
passenv = passenv =
deps = deps =
{[testenv]deps} {[testenv]deps}
@ -131,6 +129,7 @@ deps =
astroid==1.4.4 astroid==1.4.4
pylint==1.5.4 pylint==1.5.4
requests==2.9.1 requests==2.9.1
./scripts/dev/pylint_checkers
commands = commands =
{envpython} scripts/link_pyqt.py --tox {envdir} {envpython} scripts/link_pyqt.py --tox {envdir}
{envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no
@ -138,14 +137,13 @@ commands =
[testenv:pylint-tip] [testenv:pylint-tip]
basepython = python3 basepython = python3
skip_install = true
setenv = {[testenv:pylint]setenv}
passenv = {[testenv:pylint]passenv} passenv = {[testenv:pylint]passenv}
deps = deps =
{[testenv]deps} {[testenv]deps}
{[testenv:misc]deps} {[testenv:misc]deps}
hg+https://bitbucket.org/logilab/astroid hg+https://bitbucket.org/logilab/astroid
hg+https://bitbucket.org/logilab/pylint hg+https://bitbucket.org/logilab/pylint
./scripts/dev/pylint_checkers
commands = commands =
{envpython} scripts/link_pyqt.py --tox {envdir} {envpython} scripts/link_pyqt.py --tox {envdir}
{envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no