Split QtWebEngine version across multiple lines

More readable now that we have more information in it.

Also always show the source, now that we have the space for it, and "UA" isn't
the obvious default anymore anyways.
This commit is contained in:
Florian Bruhin 2024-04-30 17:33:12 +02:00
parent 5152296f7f
commit 40f6193cc7
2 changed files with 24 additions and 12 deletions

View File

@ -636,14 +636,13 @@ class WebEngineVersions:
self.chromium_major = int(self.chromium.split('.')[0])
def __str__(self) -> str:
s = f'QtWebEngine {self.webengine}'
lines = [f'QtWebEngine {self.webengine}']
if self.chromium is not None:
s += f', based on Chromium {self.chromium}'
lines.append(f' based on Chromium {self.chromium}')
if self.chromium_security is not None:
s += f', with security patches up to {self.chromium_security} (plus any distribution patches)'
if self.source != 'UA':
s += f' (from {self.source})'
return s
lines.append(f' with security patches up to {self.chromium_security} (plus any distribution patches)')
lines.append(f' (source: {self.source})')
return "\n".join(lines)
@classmethod
def from_ua(cls, ua: 'websettings.UserAgent') -> 'WebEngineVersions':

View File

@ -899,21 +899,32 @@ class TestWebEngineVersions:
webengine=utils.VersionNumber(5, 15, 2),
chromium=None,
source='UA'),
"QtWebEngine 5.15.2",
(
"QtWebEngine 5.15.2\n"
" (source: UA)"
),
),
(
version.WebEngineVersions(
webengine=utils.VersionNumber(5, 15, 2),
chromium='87.0.4280.144',
source='UA'),
"QtWebEngine 5.15.2, based on Chromium 87.0.4280.144",
(
"QtWebEngine 5.15.2\n"
" based on Chromium 87.0.4280.144\n"
" (source: UA)"
),
),
(
version.WebEngineVersions(
webengine=utils.VersionNumber(5, 15, 2),
chromium='87.0.4280.144',
source='faked'),
"QtWebEngine 5.15.2, based on Chromium 87.0.4280.144 (from faked)",
(
"QtWebEngine 5.15.2\n"
" based on Chromium 87.0.4280.144\n"
" (source: faked)"
),
),
(
version.WebEngineVersions(
@ -922,8 +933,10 @@ class TestWebEngineVersions:
chromium_security='9000.1',
source='faked'),
(
"QtWebEngine 5.15.2, based on Chromium 87.0.4280.144, with security "
"patches up to 9000.1 (plus any distribution patches) (from faked)"
"QtWebEngine 5.15.2\n"
" based on Chromium 87.0.4280.144\n"
" with security patches up to 9000.1 (plus any distribution patches)\n"
" (source: faked)"
),
),
])
@ -1319,7 +1332,7 @@ def test_version_info(params, stubs, monkeypatch, config_stub):
else:
monkeypatch.delattr(version, 'qtutils.qWebKitVersion', raising=False)
patches['objects.backend'] = usertypes.Backend.QtWebEngine
substitutions['backend'] = 'QtWebEngine 1.2.3 (from faked)'
substitutions['backend'] = 'QtWebEngine 1.2.3\n (source: faked)'
if params.known_distribution:
patches['distribution'] = lambda: version.DistributionInfo(