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

View File

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