qt: Improve SelectionInfo.__str__()
This commit is contained in:
parent
ca4cd3a24f
commit
b9253c90fe
|
|
@ -105,13 +105,14 @@ class SelectionInfo:
|
|||
# No autoselect -> shorter output
|
||||
return f"Qt wrapper: {self.wrapper} (via {self.reason.value})"
|
||||
|
||||
lines = ["Qt wrapper info:"]
|
||||
if self.pyqt5 is not None:
|
||||
lines.append(f"PyQt5: {self.pyqt5}")
|
||||
if self.pyqt6 is not None:
|
||||
lines.append(f"PyQt6: {self.pyqt6}")
|
||||
|
||||
lines.append(f"selected: {self.wrapper} (via {self.reason.value})")
|
||||
pyqt5 = self.pyqt5 or "not imported"
|
||||
pyqt6 = self.pyqt6 or "not imported"
|
||||
lines = [
|
||||
"Qt wrapper info:",
|
||||
f" PyQt5: {pyqt5}",
|
||||
f" PyQt6: {pyqt6}",
|
||||
f" -> selected: {self.wrapper} (via {self.reason.value})"
|
||||
]
|
||||
return "\n".join(lines)
|
||||
|
||||
def to_html(self) -> str:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
"""Test qutebrowser.qt.machinery."""
|
||||
|
||||
import sys
|
||||
import html
|
||||
import argparse
|
||||
import typing
|
||||
from typing import Any, Optional, Dict, Union
|
||||
|
|
@ -116,16 +117,17 @@ def test_selectioninfo_use_wrapper():
|
|||
),
|
||||
(
|
||||
"Qt wrapper info:\n"
|
||||
"PyQt5: ImportError: Python imploded\n"
|
||||
"PyQt6: success\n"
|
||||
"selected: PyQt6 (via autoselect)"
|
||||
" PyQt5: ImportError: Python imploded\n"
|
||||
" PyQt6: success\n"
|
||||
" -> selected: PyQt6 (via autoselect)"
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_selectioninfo_str(info: machinery.SelectionInfo, expected: str):
|
||||
assert str(info) == expected
|
||||
assert info.to_html() == expected.replace("\n", "<br>")
|
||||
# The test is somewhat duplicating the logic here, but it's a good sanity check.
|
||||
assert info.to_html() == html.escape(expected).replace("\n", "<br>")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
Loading…
Reference in New Issue