Fix flake8 errors

This commit is contained in:
Raymond Sun 2021-06-14 15:57:50 +10:00
parent c9aefa4a26
commit 6a9cc9e5ea
2 changed files with 13 additions and 2 deletions

View File

@ -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
@ -222,7 +228,10 @@ def ask_user(d: Dict) -> None:
'selected root path.')))
print(__('sphinx-quickstart will not overwrite existing Sphinx projects.'))
print()
sys.exit(1)
d['path'] = do_prompt(__('Please enter a new root path (or just Enter to exit)'),
'', is_path_or_empty)
if not d['path']:
sys.exit(1)
if 'sep' not in d:
print()

View File

@ -123,6 +123,7 @@ def test_quickstart_defaults(tempdir):
assert (tempdir / 'Makefile').isfile()
assert (tempdir / 'make.bat').isfile()
def test_quickstart_all_answers(tempdir):
answers = {
'Root path': tempdir,
@ -251,12 +252,13 @@ def test_extensions(tempdir):
exec(conffile.read_text(), ns)
assert ns['extensions'] == ['foo', 'bar', 'baz']
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)
qs.term_input = mock_input({})
d = {}
with pytest.raises(SystemExit):