当前位置: 首页>>代码示例>>Python>>正文


Python TextDocument.deleteLine方法代码示例

本文整理汇总了Python中vai.models.TextDocument.TextDocument.deleteLine方法的典型用法代码示例。如果您正苦于以下问题:Python TextDocument.deleteLine方法的具体用法?Python TextDocument.deleteLine怎么用?Python TextDocument.deleteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vai.models.TextDocument.TextDocument的用法示例。


在下文中一共展示了TextDocument.deleteLine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testDeleteLine2

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import deleteLine [as 别名]
    def testDeleteLine2(self):
        doc = TextDocument()
        doc.open(fixtures.get("basic_nonempty_file.txt"))

        self.assertEqual(doc.lineText(1), 'hello\n')
        self.assertEqual(doc.lineText(2), 'how are you?\n')
        self.assertEqual(doc.numLines(), 2)
        self.assertFalse(doc.isModified())

        self.assertRaises(IndexError, lambda :  doc.deleteLine(5))
        self.assertEqual(doc.lineText(1), 'hello\n')
        self.assertEqual(doc.lineText(2), 'how are you?\n')
        self.assertEqual(doc.numLines(), 2)
        self.assertFalse(doc.isModified())

        doc.deleteLine(2)
        self.assertEqual(doc.lineText(1), 'hello\n')
        self.assertEqual(doc.numLines(), 1)
        self.assertFalse(doc.isEmpty())
        self.assertTrue(doc.isModified())

        doc.deleteLine(1)
        self.assertEqual(doc.lineText(1), '\n')
        self.assertEqual(doc.numLines(), 1)
        self.assertTrue(doc.isEmpty())
        self.assertTrue(doc.isModified())
开发者ID:gavd89,项目名称:vai,代码行数:28,代码来源:test_TextDocument.py

示例2: testIsEmpty

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import deleteLine [as 别名]
    def testIsEmpty(self):
        doc = TextDocument()

        self.assertTrue(doc.isEmpty())
        doc.insertLine(1, "hello")

        self.assertFalse(doc.isEmpty())

        doc.deleteLine(1)
        self.assertTrue(doc.isEmpty())
开发者ID:gavd89,项目名称:vai,代码行数:12,代码来源:test_TextDocument.py

示例3: testChangeLineNumber

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import deleteLine [as 别名]
    def testChangeLineNumber(self):
        doc = TextDocument()
        doc.createLineMetaInfo("whatever")
        doc.createLineMetaInfo("whatever2")
        meta_info1 = doc.lineMetaInfo("whatever")
        meta_info2 = doc.lineMetaInfo("whatever2")

        meta_info1.setData("hello", 1)
        meta_info2.setData("byebye", 1)

        doc.newLineAfter(1)

        self.assertEqual(meta_info1.numLines(), 2)
        self.assertEqual(meta_info2.numLines(), 2)

        self.assertEqual(meta_info1.data(1,2), ["hello", None])
        self.assertEqual(meta_info2.data(1,2), ["byebye", None])

        doc.newLine(1)

        self.assertEqual(meta_info1.numLines(), 3)
        self.assertEqual(meta_info2.numLines(), 3)

        self.assertEqual(meta_info1.data(1,3), [None, "hello", None])
        self.assertEqual(meta_info2.data(1,3), [None, "byebye", None])

        doc.deleteLine(2)

        self.assertEqual(meta_info1.numLines(), 2)
        self.assertEqual(meta_info2.numLines(), 2)

        self.assertEqual(meta_info1.data(1,2), [None, None])
        self.assertEqual(meta_info2.data(1,2), [None, None])

        self.assertEqual(meta_info1.data(1,1), [None])
        self.assertEqual(meta_info2.data(1,1), [None])

        self.assertEqual(meta_info1.data(1), None)
        self.assertEqual(meta_info2.data(1), None)
开发者ID:UtahDave,项目名称:vai,代码行数:41,代码来源:test_LineMetaInfo.py

示例4: testLineMetaInfoMemento

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import deleteLine [as 别名]
    def testLineMetaInfoMemento(self):
        doc = TextDocument()
        doc.createLineMetaInfo("whatever")
        doc.createLineMetaInfo("whatever2")

        meta_info1 = doc.lineMetaInfo("whatever")
        meta_info2 = doc.lineMetaInfo("whatever2")
        doc.newLineAfter(1)
        doc.newLine(1)

        meta_info1.setData("hello", 1)
        meta_info2.setData("byebye", 1)

        memento = doc.lineMemento(1)

        doc.deleteLine(1)
        self.assertEqual(doc.lineMetaInfo("whatever").data(1), None)
        self.assertEqual(doc.lineMetaInfo("whatever2").data(1), None)

        doc.insertFromMemento(1, memento)
        self.assertEqual(doc.lineText(1), "\n")
        self.assertEqual(doc.lineMetaInfo("whatever").data(1), "hello")
        self.assertEqual(doc.lineMetaInfo("whatever2").data(1), "byebye")
开发者ID:rsdenijs,项目名称:vai,代码行数:25,代码来源:test_TextDocument.py

示例5: testDeleteLine2

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import deleteLine [as 别名]
    def testDeleteLine2(self):
        doc = TextDocument()
        with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
            doc.read(f)

        self.assertEqual(doc.lineText(1), "hello\n")
        self.assertEqual(doc.lineText(2), "how are you?\n")
        self.assertEqual(doc.numLines(), 2)

        self.assertRaises(IndexError, lambda: doc.deleteLine(5))
        self.assertEqual(doc.lineText(1), "hello\n")
        self.assertEqual(doc.lineText(2), "how are you?\n")
        self.assertEqual(doc.numLines(), 2)

        doc.deleteLine(2)
        self.assertEqual(doc.lineText(1), "hello\n")
        self.assertEqual(doc.numLines(), 1)
        self.assertFalse(doc.isEmpty())

        doc.deleteLine(1)
        self.assertEqual(doc.lineText(1), "\n")
        self.assertEqual(doc.numLines(), 1)
        self.assertTrue(doc.isEmpty())
开发者ID:rsdenijs,项目名称:vai,代码行数:25,代码来源:test_TextDocument.py


注:本文中的vai.models.TextDocument.TextDocument.deleteLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。