Print style name in version info.

This commit is contained in:
Florian Bruhin 2015-06-24 20:37:48 +02:00
parent 24424a0486
commit 220ac021f0
2 changed files with 16 additions and 8 deletions

View File

@ -30,6 +30,7 @@ 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.QtWebKit import qWebKitVersion
from PyQt5.QtNetwork import QSslSocket from PyQt5.QtNetwork import QSslSocket
from PyQt5.QtWidgets import QApplication
import qutebrowser import qutebrowser
from qutebrowser.utils import log, utils from qutebrowser.utils import log, utils
@ -189,12 +190,14 @@ def version():
gitver = _git_str() gitver = _git_str()
if gitver is not None: if gitver is not None:
lines.append("Git commit: {}".format(gitver)) lines.append("Git commit: {}".format(gitver))
style = QApplication.instance().style()
lines += [ lines += [
'', '',
'{}: {}'.format(platform.python_implementation(), '{}: {}'.format(platform.python_implementation(),
platform.python_version()), platform.python_version()),
'Qt: {}, runtime: {}'.format(QT_VERSION_STR, qVersion()), 'Qt: {}, runtime: {}'.format(QT_VERSION_STR, qVersion()),
'PyQt: {}'.format(PYQT_VERSION_STR), 'PyQt: {}'.format(PYQT_VERSION_STR),
'Style: {}'.format(style.metaObject().className()),
] ]
lines += _module_versions() lines += _module_versions()

View File

@ -607,38 +607,43 @@ class TestVersion:
lines = version.version().splitlines() lines = version.version().splitlines()
assert lines[4] == 'PyQt: 78.9' assert lines[4] == 'PyQt: 78.9'
def test_style(self, monkeypatch):
"""Test the style in the output."""
lines = version.version().splitlines()
assert lines[5].startswith('Style: ')
def test_module_versions(self, monkeypatch): def test_module_versions(self, monkeypatch):
"""Test module versions in the output.""" """Test module versions in the output."""
monkeypatch.setattr('qutebrowser.utils.version._module_versions', monkeypatch.setattr('qutebrowser.utils.version._module_versions',
lambda: ['Hello', 'World']) lambda: ['Hello', 'World'])
lines = version.version().splitlines() lines = version.version().splitlines()
assert (lines[5], lines[6]) == ('Hello', 'World') assert (lines[6], lines[7]) == ('Hello', 'World')
def test_webkit_version(self, monkeypatch): def test_webkit_version(self, monkeypatch):
"""Test the webkit version in the output.""" """Test the webkit version in the output."""
monkeypatch.setattr('qutebrowser.utils.version.qWebKitVersion', monkeypatch.setattr('qutebrowser.utils.version.qWebKitVersion',
lambda: '567.1') lambda: '567.1')
lines = version.version().splitlines() lines = version.version().splitlines()
assert lines[5] == 'Webkit: 567.1' assert lines[6] == 'Webkit: 567.1'
def test_harfbuzz_none(self, monkeypatch): def test_harfbuzz_none(self, monkeypatch):
"""Test harfbuzz output with QT_HARFBUZZ unset.""" """Test harfbuzz output with QT_HARFBUZZ unset."""
monkeypatch.delenv('QT_HARFBUZZ', raising=False) monkeypatch.delenv('QT_HARFBUZZ', raising=False)
lines = version.version().splitlines() lines = version.version().splitlines()
assert lines[6] == 'Harfbuzz: system' assert lines[7] == 'Harfbuzz: system'
def test_harfbuzz_set(self, monkeypatch): def test_harfbuzz_set(self, monkeypatch):
"""Test harfbuzz output with QT_HARFBUZZ set.""" """Test harfbuzz output with QT_HARFBUZZ set."""
monkeypatch.setenv('QT_HARFBUZZ', 'new') monkeypatch.setenv('QT_HARFBUZZ', 'new')
lines = version.version().splitlines() lines = version.version().splitlines()
assert lines[6] == 'Harfbuzz: new' assert lines[7] == 'Harfbuzz: new'
def test_ssl(self, monkeypatch): def test_ssl(self, monkeypatch):
"""Test SSL version in the output.""" """Test SSL version in the output."""
monkeypatch.setattr('qutebrowser.utils.version.QSslSocket', monkeypatch.setattr('qutebrowser.utils.version.QSslSocket',
FakeQSslSocket('1.0.1')) FakeQSslSocket('1.0.1'))
lines = version.version().splitlines() lines = version.version().splitlines()
assert lines[7] == 'SSL: 1.0.1' assert lines[8] == 'SSL: 1.0.1'
@pytest.mark.parametrize('frozen, expected', [(True, 'Frozen: True'), @pytest.mark.parametrize('frozen, expected', [(True, 'Frozen: True'),
(False, 'Frozen: False')]) (False, 'Frozen: False')])
@ -649,7 +654,7 @@ class TestVersion:
else: else:
monkeypatch.delattr(sys, 'frozen', raising=False) monkeypatch.delattr(sys, 'frozen', raising=False)
lines = version.version().splitlines() lines = version.version().splitlines()
assert lines[9] == expected assert lines[10] == expected
def test_platform(self, monkeypatch): def test_platform(self, monkeypatch):
"""Test platform in the version output.""" """Test platform in the version output."""
@ -658,11 +663,11 @@ class TestVersion:
monkeypatch.setattr('qutebrowser.utils.version.platform.architecture', monkeypatch.setattr('qutebrowser.utils.version.platform.architecture',
lambda: ('64bit', '')) lambda: ('64bit', ''))
lines = version.version().splitlines() lines = version.version().splitlines()
assert lines[10] == 'Platform: toaster, 64bit' assert lines[11] == 'Platform: toaster, 64bit'
def test_os_info(self, monkeypatch): def test_os_info(self, monkeypatch):
"""Test OS info in the output.""" """Test OS info in the output."""
monkeypatch.setattr('qutebrowser.utils.version._os_info', monkeypatch.setattr('qutebrowser.utils.version._os_info',
lambda: ['Hello', 'World']) lambda: ['Hello', 'World'])
lines = version.version().splitlines() lines = version.version().splitlines()
assert (lines[11], lines[12]) == ('Hello', 'World') assert (lines[12], lines[13]) == ('Hello', 'World')