Make QtWebKit optional in utils.version

This commit is contained in:
Florian Bruhin 2016-08-10 14:59:04 +02:00
parent 5b2ae3cec7
commit b488d7f9fd
2 changed files with 25 additions and 13 deletions

View File

@ -29,10 +29,14 @@ import importlib
import collections
from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, qVersion
from PyQt5.QtWebKit import qWebKitVersion
from PyQt5.QtNetwork import QSslSocket
from PyQt5.QtWidgets import QApplication
try:
from PyQt5.QtWebKit import qWebKitVersion
except ImportError:
qWebKitVersion = None
import qutebrowser
from qutebrowser.utils import log, utils
from qutebrowser.browser import pdfjs
@ -225,9 +229,14 @@ def version():
lines += _module_versions()
lines += ['pdf.js: {}'.format(_pdfjs_version())]
if qWebKitVersion is None:
lines.append('Webkit: no')
else:
lines.append('Webkit: {}'.format(qWebKitVersion()))
lines += [
'pdf.js: {}'.format(_pdfjs_version()),
'Webkit: {}'.format(qWebKitVersion()),
'Harfbuzz: {}'.format(os.environ.get('QT_HARFBUZZ', 'system')),
'SSL: {}'.format(QSslSocket.sslLibraryVersionString()),
'',

View File

@ -614,16 +614,18 @@ class FakeQSslSocket:
return self._version
@pytest.mark.parametrize('git_commit, harfbuzz, frozen, style, equal_qt', [
(True, True, False, True, True), # normal
(False, True, False, True, True), # no git commit
(True, False, False, True, True), # HARFBUZZ unset
(True, True, True, True, True), # frozen
(True, True, True, False, True), # no style
(True, True, False, True, False), # different Qt
@pytest.mark.parametrize(['git_commit', 'harfbuzz', 'frozen', 'style',
'equal_qt', 'with_webkit'], [
(True, True, False, True, True, True), # normal
(False, True, False, True, True, True), # no git commit
(True, False, False, True, True, True), # HARFBUZZ unset
(True, True, True, True, True, True), # frozen
(True, True, True, False, True, True), # no style
(True, True, False, True, False, True), # different Qt
(True, True, False, True, True, False), # no webkit
])
def test_version_output(git_commit, harfbuzz, frozen, style, equal_qt,
stubs, monkeypatch):
with_webkit, stubs, monkeypatch):
"""Test version.version()."""
import_path = os.path.abspath('/IMPORTPATH')
patches = {
@ -638,7 +640,7 @@ def test_version_output(git_commit, harfbuzz, frozen, style, equal_qt,
'QT VERSION' if equal_qt else 'QT RUNTIME VERSION'),
'_module_versions': lambda: ['MODULE VERSION 1', 'MODULE VERSION 2'],
'_pdfjs_version': lambda: 'PDFJS VERSION',
'qWebKitVersion': lambda: 'WEBKIT VERSION',
'qWebKitVersion': (lambda: 'WEBKIT VERSION') if with_webkit else None,
'QSslSocket': FakeQSslSocket('SSL VERSION'),
'platform.platform': lambda: 'PLATFORM',
'platform.architecture': lambda: ('ARCHITECTURE', ''),
@ -672,7 +674,7 @@ def test_version_output(git_commit, harfbuzz, frozen, style, equal_qt,
MODULE VERSION 1
MODULE VERSION 2
pdf.js: PDFJS VERSION
Webkit: WEBKIT VERSION
Webkit: {webkit}
Harfbuzz: {harfbuzz}
SSL: SSL VERSION
{style}
@ -692,6 +694,7 @@ def test_version_output(git_commit, harfbuzz, frozen, style, equal_qt,
'harfbuzz': 'HARFBUZZ' if harfbuzz else 'system',
'frozen': str(frozen),
'import_path': import_path,
'webkit': 'WEBKIT VERSION' if with_webkit else 'no'
}
expected = template.rstrip('\n').format(**substitutions)