Make quickstart just exit without reprompting

This commit is contained in:
Raymond Sun 2021-06-12 00:07:34 +10:00
parent 025db04658
commit 81049deed6
2 changed files with 5 additions and 11 deletions

View File

@ -220,11 +220,8 @@ def ask_user(d: Dict) -> None:
print()
print(bold(__('Error: an existing conf.py has been found in the '
'selected root path.')))
print(__('sphinx-quickstart will not overwrite existing Sphinx projects.'))
print(__('sphinx-quickstart will not overwrite existing Sphinx projects. Try another directory?'))
print()
d['path'] = do_prompt(__('Please enter a new root path (or just Enter to exit)'),
'', ok)
if not d['path']:
sys.exit(1)
if 'sep' not in d:

View File

@ -251,16 +251,13 @@ def test_extensions(tempdir):
exec(conffile.read_text(), ns)
assert ns['extensions'] == ['foo', 'bar', 'baz']
def test_easy_exit_when_existing_confpy(monkeypatch):
def test_exits_upon_existing_confpy(monkeypatch):
# The code detects existing conf.py with isfile() so we mock it
def mock_isfile(path):
return True
monkeypatch.setattr(path, 'isfile', mock_isfile)
answers = {
'Please enter a new root path': '',
}
qs.term_input = mock_input(answers)
qs.term_input = mock_input({})
d = {}
with pytest.raises(SystemExit):
qs.ask_user(d)