Exemple #1
0
    def testGetBufferCursorPos(self):
        f = fixtures.get("editor_state")
        paths.stateFile = lambda : f
        state = EditorState.instance()

        self.assertEqual(state.cursorPosForPath('foobar'), (1,2))
        self.assertEqual(state.cursorPosForPath('notpresent'), None)
Exemple #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]}]}"))
Exemple #3
0
 def testInit(self):
     f = fixtures.tempFile("not_there_editor_state")
     paths.stateFile = lambda : f
     state = EditorState.instance()
     self.assertEqual(state._state, {})