本文整理匯總了Python中vai.models.TextDocument.TextDocument.deleteChars方法的典型用法代碼示例。如果您正苦於以下問題:Python TextDocument.deleteChars方法的具體用法?Python TextDocument.deleteChars怎麽用?Python TextDocument.deleteChars使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vai.models.TextDocument.TextDocument
的用法示例。
在下文中一共展示了TextDocument.deleteChars方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testDeleteChars
# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import deleteChars [as 別名]
def testDeleteChars(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
self.assertRaises(ValueError, lambda : doc.deleteChars((1,3), -1))
d = doc.deleteChars( (1,3), 1)
self.assertEqual(doc.lineText(1), 'helo\n')
self.assertEqual(d[0], 'l')
d = doc.deleteChars( (1,2), 100)
self.assertEqual(doc.lineText(1), 'h\n')
self.assertEqual(d[0], 'elo')
d = doc.deleteChars( (1,2), 100)
self.assertEqual(doc.lineText(1), 'h\n')
self.assertEqual(d[0], '')
d = doc.deleteChars( (1,1), 100)
self.assertEqual(doc.lineText(1), '\n')
self.assertEqual(d[0], 'h')
d = doc.deleteChars( (1,1), 100)
self.assertEqual(doc.lineText(1), '\n')
self.assertEqual(d[0], '')
示例2: testDeleteChars
# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import deleteChars [as 別名]
def testDeleteChars(self):
doc = TextDocument()
with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
doc.read(f)
self.assertRaises(ValueError, lambda: doc.deleteChars((1, 3), -1))
d = doc.deleteChars((1, 3), 1)
self.assertEqual(doc.lineText(1), "helo\n")
self.assertEqual(d[0], "l")
d = doc.deleteChars((1, 2), 100)
self.assertEqual(doc.lineText(1), "h\n")
self.assertEqual(d[0], "elo")
d = doc.deleteChars((1, 2), 100)
self.assertEqual(doc.lineText(1), "h\n")
self.assertEqual(d[0], "")
d = doc.deleteChars((1, 1), 100)
self.assertEqual(doc.lineText(1), "\n")
self.assertEqual(d[0], "h")
d = doc.deleteChars((1, 1), 100)
self.assertEqual(doc.lineText(1), "\n")
self.assertEqual(d[0], "")