Merge branch 'EliteTK-editor_crash_behaviour'
This commit is contained in:
commit
d8c999aa73
@ -58,7 +58,8 @@ class ExternalEditor(QObject):
|
||||
return
|
||||
try:
|
||||
os.close(self._oshandle)
|
||||
os.remove(self._filename)
|
||||
if self._proc.exit_status() != QProcess.CrashExit:
|
||||
os.remove(self._filename)
|
||||
except OSError as e:
|
||||
# NOTE: Do not replace this with "raise CommandError" as it's
|
||||
# executed async.
|
||||
|
@ -160,3 +160,6 @@ class GUIProcess(QObject):
|
||||
else:
|
||||
message.error(self._win_id, "Error while spawning {}: {}.".format(
|
||||
self._what, self._proc.error()), immediately=True)
|
||||
|
||||
def exit_status(self):
|
||||
return self._proc.exitStatus()
|
||||
|
@ -98,19 +98,28 @@ class TestFileHandling:
|
||||
filename = editor._filename
|
||||
assert os.path.exists(filename)
|
||||
|
||||
editor._proc._proc.exitStatus = mock.Mock(
|
||||
return_value=QProcess.CrashExit)
|
||||
editor._proc.finished.emit(1, QProcess.NormalExit)
|
||||
|
||||
assert not os.path.exists(filename)
|
||||
assert os.path.exists(filename)
|
||||
|
||||
os.remove(filename)
|
||||
|
||||
def test_crash(self, editor):
|
||||
"""Test file handling when closing with a crash."""
|
||||
editor.edit("")
|
||||
filename = editor._filename
|
||||
assert os.path.exists(filename)
|
||||
|
||||
editor._proc._proc.exitStatus = mock.Mock(
|
||||
return_value=QProcess.CrashExit)
|
||||
editor._proc.error.emit(QProcess.Crashed)
|
||||
|
||||
editor._proc.finished.emit(0, QProcess.CrashExit)
|
||||
assert not os.path.exists(filename)
|
||||
assert os.path.exists(filename)
|
||||
|
||||
os.remove(filename)
|
||||
|
||||
@pytest.mark.posix
|
||||
def test_unreadable(self, message_mock, editor):
|
||||
|
Loading…
Reference in New Issue
Block a user