Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ disallow_untyped_defs = false
[[tool.mypy.overrides]]
module = [
# tests/
"tests.test_quickstart",
"tests.test_search",
# tests/test_builders
"tests.test_builders.test_build_latex",
Expand Down
3 changes: 2 additions & 1 deletion sphinx/cmd/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@


# function to get input from terminal -- overridden by the test suite
def term_input(prompt: str) -> str:
# Arguments are positional-only to match ``input``.
def term_input(prompt: str, /) -> str:
if sys.platform == 'win32':
# Important: On windows, readline is not enabled by default. In these
# environment, escape sequences have been broken. To avoid the
Expand Down
24 changes: 12 additions & 12 deletions tests/test_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
warnfile = StringIO()


def setup_module():
def setup_module() -> None:
disable_colour()


Expand Down Expand Up @@ -48,7 +48,7 @@ def input_(prompt: str) -> str:
real_input: Callable[[str], str] = input


def teardown_module():
def teardown_module() -> None:
qs.term_input = real_input
enable_colour()

Expand All @@ -61,7 +61,7 @@ def test_do_prompt() -> None:
'Q5': 'no',
'Q6': 'foo',
}
qs.term_input = mock_input(answers) # type: ignore[assignment]
qs.term_input = mock_input(answers)

assert qs.do_prompt('Q1', default='v1') == 'v1'
assert qs.do_prompt('Q3', default='v3_default') == 'v3'
Expand All @@ -79,7 +79,7 @@ def test_do_prompt_inputstrip() -> None:
'Q3': 'N',
'Q4': 'N ',
}
qs.term_input = mock_input(answers) # type: ignore[assignment]
qs.term_input = mock_input(answers)

assert qs.do_prompt('Q1') == 'Y'
assert qs.do_prompt('Q2') == 'Yes'
Expand All @@ -91,12 +91,12 @@ def test_do_prompt_with_nonascii() -> None:
answers = {
'Q1': '\u30c9\u30a4\u30c4',
}
qs.term_input = mock_input(answers) # type: ignore[assignment]
qs.term_input = mock_input(answers)
result = qs.do_prompt('Q1', default='\u65e5\u672c')
assert result == '\u30c9\u30a4\u30c4'


def test_quickstart_defaults(tmp_path):
def test_quickstart_defaults(tmp_path: Path) -> None:
answers = {
'Root path': str(tmp_path),
'Project name': 'Sphinx Test',
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_quickstart_defaults(tmp_path):
assert (tmp_path / 'make.bat').is_file()


def test_quickstart_all_answers(tmp_path):
def test_quickstart_all_answers(tmp_path: Path) -> None:
answers = {
'Root path': str(tmp_path),
'Separate source and build': 'y',
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_quickstart_all_answers(tmp_path):
assert (tmp_path / 'source' / 'contents.txt').is_file()


def test_generated_files_eol(tmp_path):
def test_generated_files_eol(tmp_path: Path) -> None:
answers = {
'Root path': str(tmp_path),
'Project name': 'Sphinx Test',
Expand All @@ -205,7 +205,7 @@ def assert_eol(filename: Path, eol: str) -> None:
assert_eol(tmp_path / 'Makefile', '\n')


def test_quickstart_and_build(tmp_path):
def test_quickstart_and_build(tmp_path: Path) -> None:
answers = {
'Root path': str(tmp_path),
'Project name': 'Fullwidth characters: \u30c9\u30a4\u30c4',
Expand All @@ -224,7 +224,7 @@ def test_quickstart_and_build(tmp_path):
assert not warnings


def test_default_filename(tmp_path):
def test_default_filename(tmp_path: Path) -> None:
answers = {
'Root path': str(tmp_path),
'Project name': '\u30c9\u30a4\u30c4', # Fullwidth characters only
Expand All @@ -242,7 +242,7 @@ def test_default_filename(tmp_path):
exec(conffile.read_text(encoding='utf8'), ns) # NoQA: S102


def test_extensions(tmp_path):
def test_extensions(tmp_path: Path) -> None:
qs.main([
'-q',
'-p',
Expand All @@ -261,7 +261,7 @@ def test_extensions(tmp_path):
assert ns['extensions'] == ['foo', 'bar', 'baz']


def test_exits_when_existing_confpy(monkeypatch):
def test_exits_when_existing_confpy(monkeypatch: pytest.MonkeyPatch) -> None:
# The code detects existing conf.py with path.is_file()
# so we mock it as True with pytest's monkeypatch
monkeypatch.setattr('os.path.isfile', lambda path: True)
Expand Down
Loading