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)
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]}]}"))
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]}]}"))
def testSave(self): path = fixtures.tempFile("testSave") doc = TextDocument() with open(path, 'w') as f: doc.write(f) self.assertTrue(os.path.exists(path))
def testInit(self): f = fixtures.tempFile("not_there_editor_state") paths.stateFile = lambda : f state = EditorState.instance() self.assertEqual(state._state, {})
def testSave(self): path = fixtures.tempFile("testSave") doc = TextDocument() doc.setFilename(path) doc.save() self.assertTrue(os.path.exists(path))
def testSave(self): path = fixtures.tempFile("testSave") doc = TextDocument() with open(path, "w") as f: doc.write(f) self.assertTrue(os.path.exists(path))
def testInit(self): f = fixtures.tempFile("not_there_editor_state") EditorState.editorStatePath = lambda x : f state = EditorState.instance() self.assertEqual(state._state, {})