Exemplo n.º 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)
Exemplo n.º 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]}]}"))
Exemplo n.º 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]}]}"))
Exemplo n.º 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))
Exemplo n.º 5
0
 def testInit(self):
     f = fixtures.tempFile("not_there_editor_state")
     paths.stateFile = lambda : f
     state = EditorState.instance()
     self.assertEqual(state._state, {})
Exemplo n.º 6
0
 def testSave(self):
     path = fixtures.tempFile("testSave")
     doc = TextDocument()
     doc.setFilename(path)
     doc.save()
     self.assertTrue(os.path.exists(path))
Exemplo n.º 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))
Exemplo n.º 8
0
 def testInit(self):
     f = fixtures.tempFile("not_there_editor_state")
     EditorState.editorStatePath = lambda x : f
     state = EditorState.instance()
     self.assertEqual(state._state, {})