tests: Disable word wrap for rich text tests

Fixes #7267
This commit is contained in:
Florian Bruhin 2022-06-20 14:56:17 +02:00
parent c8378d0872
commit 96dfd2bbf9
1 changed files with 11 additions and 2 deletions

View File

@ -90,7 +90,11 @@ def test_word_wrap(view, qtbot):
])
@pytest.mark.parametrize("replace", ["test", None])
def test_rich_text(view, qtbot, rich, higher, expected_format, replace):
"""Rich text should be rendered appropriately."""
"""Rich text should be rendered appropriately.
This makes sure the title has been rendered as plain text by comparing the
heights of the two widgets. To ensure consistent results, we disable word-wrapping.
"""
level = usertypes.MessageLevel.info
text = 'with <h1>markup</h1>'
text2 = 'with <h1>markup</h1> 2'
@ -105,6 +109,7 @@ def test_rich_text(view, qtbot, rich, higher, expected_format, replace):
with ctx:
view.show_message(info1)
assert len(view._messages) == 1
view._messages[0].setWordWrap(False)
height1 = view.sizeHint().height()
assert height1 > 0
@ -112,10 +117,14 @@ def test_rich_text(view, qtbot, rich, higher, expected_format, replace):
assert view._messages[0].textFormat() == Qt.TextFormat.PlainText # default
view.show_message(info2)
height2 = view.sizeHint().height()
assert len(view._messages) == 1
view._messages[0].setWordWrap(False)
height2 = view.sizeHint().height()
assert height2 > 0
assert view._messages[0].textFormat() == expected_format
if higher:
assert height2 > height1
else: