Prompt for filename when saving anonymous file

This commit is contained in:
Anthony Sottile
2019-11-23 16:55:31 -08:00
parent ba4f513052
commit 7306003c3d
2 changed files with 29 additions and 9 deletions

View File

@@ -1100,11 +1100,27 @@ def test_multiple_files(tmpdir):
h.await_exit()
def test_saving_with_no_filename_doesnt_exist():
# TODO: this should prompt but currently refuses
def test_save_no_filename_specified(tmpdir):
f = tmpdir.join('f')
with run() as h, and_exit(h):
h.press('hello world')
h.press('^S')
h.await_text('no filename, not implemented')
h.await_text('enter filename:')
h.press_and_enter(str(f))
h.await_text('saved! (1 line written)')
h.await_text_missing('*')
assert f.read() == 'hello world\n'
@pytest.mark.parametrize('k', ('Enter', '^C'))
def test_save_no_filename_specified_cancel(k):
with run() as h, and_exit(h):
h.press('hello world')
h.press('^S')
h.await_text('enter filename:')
h.press(k)
h.await_text('cancelled')
def test_saving_file_on_disk_changes(tmpdir):