mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '9320' into 4.x
This commit is contained in:
commit
00d28e1e98
@ -95,6 +95,12 @@ def is_path(x: str) -> str:
|
||||
return x
|
||||
|
||||
|
||||
def is_path_or_empty(x: str) -> str:
|
||||
if x == '':
|
||||
return x
|
||||
return is_path(x)
|
||||
|
||||
|
||||
def allow_empty(x: str) -> str:
|
||||
return x
|
||||
|
||||
@ -223,7 +229,7 @@ def ask_user(d: Dict) -> None:
|
||||
print(__('sphinx-quickstart will not overwrite existing Sphinx projects.'))
|
||||
print()
|
||||
d['path'] = do_prompt(__('Please enter a new root path (or just Enter to exit)'),
|
||||
'', is_path)
|
||||
'', is_path_or_empty)
|
||||
if not d['path']:
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
import time
|
||||
from io import StringIO
|
||||
from os import path
|
||||
|
||||
import pytest
|
||||
|
||||
@ -250,3 +251,18 @@ def test_extensions(tempdir):
|
||||
ns = {}
|
||||
exec(conffile.read_text(), ns)
|
||||
assert ns['extensions'] == ['foo', 'bar', 'baz']
|
||||
|
||||
|
||||
def test_exits_when_existing_confpy(monkeypatch):
|
||||
# The code detects existing conf.py with path.isfile()
|
||||
# so we mock it as True with pytest's monkeypatch
|
||||
def mock_isfile(path):
|
||||
return True
|
||||
monkeypatch.setattr(path, 'isfile', mock_isfile)
|
||||
|
||||
qs.term_input = mock_input({
|
||||
'Please enter a new root path (or just Enter to exit)': ''
|
||||
})
|
||||
d = {}
|
||||
with pytest.raises(SystemExit):
|
||||
qs.ask_user(d)
|
||||
|
Loading…
Reference in New Issue
Block a user