Пример #1
0
    def testInitEmpty(self):
        doc = TextDocument()

        self.assertTrue(doc.isEmpty())
        self.assertEqual(doc.filename(), None)
        self.assertFalse(doc.isModified())
        self.assertEqual(doc.numLines(), 1)
        self.assertEqual(doc.documentText(), '\n')
Пример #2
0
    def testSaveUnnamed(self):
        doc = TextDocument()
        self.assertRaises(TextDocument.MissingFilenameException, lambda: doc.save())

        path = fixtures.tempFile("testSaveUnnamed")
        doc.saveAs(path)
        self.assertTrue(os.path.exists(path))
        self.assertEqual(doc.filename(), path)
Пример #3
0
    def testInitFromNonEmptyFile(self):
        doc = TextDocument()
        doc.open(fixtures.get("basic_nonempty_file.txt"))

        self.assertFalse(doc.isEmpty())
        self.assertEqual(doc.filename(), fixtures.get("basic_nonempty_file.txt"))
        self.assertFalse(doc.isModified())
        self.assertEqual(doc.numLines(), 2)
        self.assertEqual(doc.documentText(), 'hello\nhow are you?\n')
Пример #4
0
    def testInitFromEmptyFile(self):
        doc = TextDocument()
        doc.open(fixtures.get("empty_file.txt"))

        self.assertTrue(doc.isEmpty())
        self.assertEqual(doc.filename(), fixtures.get("empty_file.txt"))
        self.assertFalse(doc.isModified())
        self.assertEqual(doc.numLines(), 1)
        self.assertEqual(doc.documentText(), '\n')