diff --git a/tests/src/python/test_qgstextdocument.py b/tests/src/python/test_qgstextdocument.py
index 2bd4497482e5..dd22b62e34e3 100644
--- a/tests/src/python/test_qgstextdocument.py
+++ b/tests/src/python/test_qgstextdocument.py
@@ -85,8 +85,7 @@ def testFromHtml(self):
doc = QgsTextDocument.fromHtml(['abc
', 'b c d', 'e'])
self.assertEqual(len(doc), 5)
self.assertEqual(len(doc[0]), 1)
- self.assertTrue(doc[0].blockFormat().hasHorizontalAlignmentSet())
- self.assertEqual(doc[0].blockFormat().horizontalAlignment(), Qgis.TextHorizontalAlignment.Right)
+ self.assertFalse(doc[0].blockFormat().hasHorizontalAlignmentSet())
self.assertEqual(doc[0][0].text(), 'abc')
self.assertEqual(doc[0][0].characterFormat().underline(), QgsTextCharacterFormat.BooleanValue.NotSet)
self.assertEqual(doc[0][0].characterFormat().italic(), QgsTextCharacterFormat.BooleanValue.NotSet)
@@ -99,6 +98,8 @@ def testFromHtml(self):
self.assertEqual(doc[1][0].text(), 'def')
self.assertEqual(doc[1][0].characterFormat().underline(), QgsTextCharacterFormat.BooleanValue.SetTrue)
self.assertEqual(doc[1][0].characterFormat().italic(), QgsTextCharacterFormat.BooleanValue.SetTrue)
+ self.assertTrue(doc[1].blockFormat().hasHorizontalAlignmentSet())
+ self.assertEqual(doc[1].blockFormat().horizontalAlignment(), Qgis.TextHorizontalAlignment.Right)
if int(QT_VERSION_STR.split('.')[0]) >= 6:
self.assertEqual(doc[1][0].characterFormat().fontWeight(), 700)
else: