def testConstructors(self): # empty frag = QgsTextFragment() self.assertFalse(frag.text()) fragment = QgsTextFragment('ludicrous gibs!') self.assertEqual(fragment.text(), 'ludicrous gibs!')
def testConstructors(self): # empty block = QgsTextBlock() self.assertEqual(len(block), 0) # single fragment block fragment = QgsTextFragment('ludicrous gibs!') block = QgsTextBlock(fragment) self.assertEqual(len(block), 1) self.assertEqual(block[0].text(), fragment.text())
def testConstructors(self): # empty doc = QgsTextDocument() self.assertEqual(len(doc), 0) # single block document block = QgsTextBlock() doc = QgsTextDocument(block) self.assertEqual(len(doc), 1) self.assertEqual(len(doc[0]), 0) # single fragment document fragment = QgsTextFragment('ludicrous gibs!') doc = QgsTextDocument(fragment) self.assertEqual(len(doc), 1) self.assertEqual(len(doc[0]), 1) self.assertEqual(doc[0][0].text(), fragment.text())
def testSetText(self): fragment = QgsTextFragment() fragment.setText('ludicrous gibs!') self.assertEqual(fragment.text(), 'ludicrous gibs!')
def testCapitalize(self): fragment = QgsTextFragment('ludicrous gibs!') fragment.applyCapitalization(QgsStringUtils.TitleCase) self.assertEqual(fragment.text(), 'Ludicrous Gibs!')