From 95592770a796331b26e61f4f94a3d2facfe6c3d4 Mon Sep 17 00:00:00 2001 From: Michal Siedlaczek Date: Sat, 12 Aug 2017 17:29:57 -0700 Subject: [PATCH] Fixing test dependencies and other test issues --- misc/requirements/requirements-tests.txt-raw | 1 + qutebrowser/browser/webengine/spell.py | 16 +++++++++------- scripts/install_dict.py | 2 +- tests/unit/browser/webengine/test_spell.py | 5 +++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/misc/requirements/requirements-tests.txt-raw b/misc/requirements/requirements-tests.txt-raw index bc44bc8e1..8693ed31f 100644 --- a/misc/requirements/requirements-tests.txt-raw +++ b/misc/requirements/requirements-tests.txt-raw @@ -17,6 +17,7 @@ pytest-repeat pytest-rerunfailures pytest-travis-fold pytest-xvfb +requests vulture #@ ignore: Jinja2, MarkupSafe, colorama diff --git a/qutebrowser/browser/webengine/spell.py b/qutebrowser/browser/webengine/spell.py index b61ca033c..66c87f2a5 100644 --- a/qutebrowser/browser/webengine/spell.py +++ b/qutebrowser/browser/webengine/spell.py @@ -1,4 +1,4 @@ -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2017 Michal Siedlaczek @@ -20,12 +20,13 @@ """Installing and configuring spell-checking for QtWebEngine.""" import os +from urllib.parse import urljoin from urllib.request import urlretrieve -from qutebrowser import basedir from PyQt5.QtCore import QLibraryInfo -repository_url = 'https://redirector.gvt1.com/edgedl/chrome/dict' +repository_url = 'https://redirector.gvt1.com/edgedl/chrome/dict/' + class Language: @@ -77,8 +78,8 @@ class Language: def get_dictionary_dir(): """Return the path to the QtWebEngine's dictionaries directory.""" - return QLibraryInfo.location(QLibraryInfo.DataPath) + \ - '/qtwebengine_dictionaries' + return os.path.join(QLibraryInfo.location(QLibraryInfo.DataPath), + '/qtwebengine_dictionaries') def get_language_list_file(): @@ -132,13 +133,14 @@ def install(languages): for lang in languages: try: print('Installing {}: {}'.format(lang.code, lang.name)) - lang_url = '{}/{}'.format(repository_url, lang.file) + lang_url = urljoin(repository_url, lang.file) if not os.path.isdir(get_dictionary_dir()): print('WARN: {} does not exist, creating the directory'.format( get_dictionary_dir())) os.makedirs(get_dictionary_dir()) print('Downloading {}'.format(lang_url)) - urlretrieve(lang_url, get_dictionary_dir() + '/' + lang.file) + urlretrieve(lang_url, + os.path.join(get_dictionary_dir(), lang.file)) print('Done.') except PermissionError as e: print(e) diff --git a/scripts/install_dict.py b/scripts/install_dict.py index 8d45f2f6b..7cedf8c23 100755 --- a/scripts/install_dict.py +++ b/scripts/install_dict.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2017 Michal Siedlaczek diff --git a/tests/unit/browser/webengine/test_spell.py b/tests/unit/browser/webengine/test_spell.py index 65e5acba9..a5c1c3db5 100644 --- a/tests/unit/browser/webengine/test_spell.py +++ b/tests/unit/browser/webengine/test_spell.py @@ -19,9 +19,10 @@ from os.path import basename -from requests import head +from urllib.parse import urljoin import pytest +from requests import head from qutebrowser.browser.webengine import spell @@ -78,6 +79,6 @@ def test_install(tmpdir, mocker): def test_available_langs(): for lang in spell.get_available_languages(): - lang_url = '{}/{}'.format(spell.repository_url, lang.file) + lang_url = urljoin(spell.repository_url, lang.file) response = head(lang_url) assert response.status_code == 302