Fixing test dependencies and other test issues

This commit is contained in:
Michal Siedlaczek 2017-08-12 17:29:57 -07:00
parent fac0e44a7e
commit 95592770a7
4 changed files with 14 additions and 10 deletions

View File

@ -17,6 +17,7 @@ pytest-repeat
pytest-rerunfailures pytest-rerunfailures
pytest-travis-fold pytest-travis-fold
pytest-xvfb pytest-xvfb
requests
vulture vulture
#@ ignore: Jinja2, MarkupSafe, colorama #@ ignore: Jinja2, MarkupSafe, colorama

View File

@ -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 <michal.siedlaczek@gmail.com> # Copyright 2017 Michal Siedlaczek <michal.siedlaczek@gmail.com>
@ -20,12 +20,13 @@
"""Installing and configuring spell-checking for QtWebEngine.""" """Installing and configuring spell-checking for QtWebEngine."""
import os import os
from urllib.parse import urljoin
from urllib.request import urlretrieve from urllib.request import urlretrieve
from qutebrowser import basedir
from PyQt5.QtCore import QLibraryInfo 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: class Language:
@ -77,8 +78,8 @@ class Language:
def get_dictionary_dir(): def get_dictionary_dir():
"""Return the path to the QtWebEngine's dictionaries directory.""" """Return the path to the QtWebEngine's dictionaries directory."""
return QLibraryInfo.location(QLibraryInfo.DataPath) + \ return os.path.join(QLibraryInfo.location(QLibraryInfo.DataPath),
'/qtwebengine_dictionaries' '/qtwebengine_dictionaries')
def get_language_list_file(): def get_language_list_file():
@ -132,13 +133,14 @@ def install(languages):
for lang in languages: for lang in languages:
try: try:
print('Installing {}: {}'.format(lang.code, lang.name)) 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()): if not os.path.isdir(get_dictionary_dir()):
print('WARN: {} does not exist, creating the directory'.format( print('WARN: {} does not exist, creating the directory'.format(
get_dictionary_dir())) get_dictionary_dir()))
os.makedirs(get_dictionary_dir()) os.makedirs(get_dictionary_dir())
print('Downloading {}'.format(lang_url)) 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.') print('Done.')
except PermissionError as e: except PermissionError as e:
print(e) print(e)

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/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 <michal.siedlaczek@gmail.com> # Copyright 2017 Michal Siedlaczek <michal.siedlaczek@gmail.com>

View File

@ -19,9 +19,10 @@
from os.path import basename from os.path import basename
from requests import head from urllib.parse import urljoin
import pytest import pytest
from requests import head
from qutebrowser.browser.webengine import spell from qutebrowser.browser.webengine import spell
@ -78,6 +79,6 @@ def test_install(tmpdir, mocker):
def test_available_langs(): def test_available_langs():
for lang in spell.get_available_languages(): 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) response = head(lang_url)
assert response.status_code == 302 assert response.status_code == 302