mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Make it easier for the test suite to override raw_input for test_quickstart.
This commit is contained in:
parent
84cba9c39c
commit
420adbce2f
@ -21,6 +21,9 @@ from sphinx.util.console import purple, bold, red, turquoise, \
|
|||||||
nocolor, color_terminal
|
nocolor, color_terminal
|
||||||
from sphinx.util import texescape
|
from sphinx.util import texescape
|
||||||
|
|
||||||
|
# function to get input from terminal -- overridden by the test suite
|
||||||
|
term_input = raw_input
|
||||||
|
|
||||||
|
|
||||||
PROMPT_PREFIX = '> '
|
PROMPT_PREFIX = '> '
|
||||||
|
|
||||||
@ -657,7 +660,7 @@ def do_prompt(d, key, text, default=None, validator=nonempty):
|
|||||||
prompt = purple(PROMPT_PREFIX + '%s [%s]: ' % (text, default))
|
prompt = purple(PROMPT_PREFIX + '%s [%s]: ' % (text, default))
|
||||||
else:
|
else:
|
||||||
prompt = purple(PROMPT_PREFIX + text + ': ')
|
prompt = purple(PROMPT_PREFIX + text + ': ')
|
||||||
x = raw_input(prompt)
|
x = term_input(prompt)
|
||||||
if default and not x:
|
if default and not x:
|
||||||
x = default
|
x = default
|
||||||
if not isinstance(x, unicode):
|
if not isinstance(x, unicode):
|
||||||
|
@ -37,7 +37,7 @@ def mock_raw_input(answers, needanswer=False):
|
|||||||
return raw_input
|
return raw_input
|
||||||
|
|
||||||
def teardown_module():
|
def teardown_module():
|
||||||
qs.raw_input = __builtin__.raw_input
|
qs.term_input = raw_input
|
||||||
qs.TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
|
qs.TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
|
||||||
coloron()
|
coloron()
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ def test_do_prompt():
|
|||||||
'Q5': 'no',
|
'Q5': 'no',
|
||||||
'Q6': 'foo',
|
'Q6': 'foo',
|
||||||
}
|
}
|
||||||
qs.raw_input = mock_raw_input(answers)
|
qs.term_input = mock_raw_input(answers)
|
||||||
try:
|
try:
|
||||||
qs.do_prompt(d, 'k1', 'Q1')
|
qs.do_prompt(d, 'k1', 'Q1')
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
@ -79,7 +79,7 @@ def test_quickstart_defaults(tempdir):
|
|||||||
'Author name': 'Georg Brandl',
|
'Author name': 'Georg Brandl',
|
||||||
'Project version': '0.1',
|
'Project version': '0.1',
|
||||||
}
|
}
|
||||||
qs.raw_input = mock_raw_input(answers)
|
qs.term_input = mock_raw_input(answers)
|
||||||
qs.inner_main([])
|
qs.inner_main([])
|
||||||
|
|
||||||
conffile = tempdir / 'conf.py'
|
conffile = tempdir / 'conf.py'
|
||||||
@ -136,7 +136,7 @@ def test_quickstart_all_answers(tempdir):
|
|||||||
'Create Windows command file': 'no',
|
'Create Windows command file': 'no',
|
||||||
'Do you want to use the epub builder': 'yes',
|
'Do you want to use the epub builder': 'yes',
|
||||||
}
|
}
|
||||||
qs.raw_input = mock_raw_input(answers, needanswer=True)
|
qs.term_input = mock_raw_input(answers, needanswer=True)
|
||||||
qs.TERM_ENCODING = 'utf-8'
|
qs.TERM_ENCODING = 'utf-8'
|
||||||
qs.inner_main([])
|
qs.inner_main([])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user