示例#1
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)
示例#2
0
    def testSaveBufferCursorPos(self):
        f = fixtures.tempFile("editor_state")
        paths.stateFile = lambda : f
        state = EditorState.instance()

        state.setCursorPosForPath("foobar", (1,2))
        self.assertEqual(state.cursorPosForPath('foobar'), (1,2))

        state.save()
        self.assertTrue(os.path.exists(f))
        with open(f, "r") as tmp:
            # Just checking lengths. the order is arbitrary.
            self.assertEqual(len(tmp.read()),
                            len("{'buffers': [{'absolute_path': 'foobar', 'cursor_pos': [1, 2]}]}"))
示例#3
0
    def testSaveBufferCursorPos(self):
        f = fixtures.tempFile("editor_state")
        EditorState.editorStatePath = lambda x : f
        state = EditorState.instance()

        state.setCursorPosForPath("foobar", (1,2))
        self.assertEqual(state.cursorPosForPath('foobar'), (1,2))

        state.save()
        self.assertTrue(os.path.exists(f))
        with contextlib.closing(open(f, "r")) as tmp:
            # Just checking lengths. the order is arbitrary.
            self.assertEqual(len(tmp.read()),
                            len("{'buffers': [{'absolute_path': 'foobar', 'cursor_pos': [1, 2]}]}"))
示例#4
0
 def testSave(self):
     path = fixtures.tempFile("testSave")
     doc = TextDocument()
     with open(path, 'w') as f:
         doc.write(f)
     self.assertTrue(os.path.exists(path))
示例#5
0
 def testInit(self):
     f = fixtures.tempFile("not_there_editor_state")
     paths.stateFile = lambda : f
     state = EditorState.instance()
     self.assertEqual(state._state, {})
示例#6
0
 def testSave(self):
     path = fixtures.tempFile("testSave")
     doc = TextDocument()
     doc.setFilename(path)
     doc.save()
     self.assertTrue(os.path.exists(path))
示例#7
0
 def testSave(self):
     path = fixtures.tempFile("testSave")
     doc = TextDocument()
     with open(path, "w") as f:
         doc.write(f)
     self.assertTrue(os.path.exists(path))
示例#8
0
 def testInit(self):
     f = fixtures.tempFile("not_there_editor_state")
     EditorState.editorStatePath = lambda x : f
     state = EditorState.instance()
     self.assertEqual(state._state, {})