summaryrefslogtreecommitdiff
path: root/tests/test_quickstart.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_quickstart.py')
-rw-r--r--tests/test_quickstart.py74
1 files changed, 27 insertions, 47 deletions
diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py
index a4f12a551..b1b0fc535 100644
--- a/tests/test_quickstart.py
+++ b/tests/test_quickstart.py
@@ -16,10 +16,8 @@ from six import PY2, text_type, StringIO
from six.moves import input
import pytest
-from sphinx.testing.util import SkipTest
-
from sphinx import application
-from sphinx import quickstart as qs
+from sphinx.cmd import quickstart as qs
from sphinx.util.console import nocolor, coloron
from sphinx.util.pycompat import execfile_
@@ -63,27 +61,7 @@ def teardown_module():
coloron()
-def test_quickstart_inputstrip():
- d = {}
- answers = {
- 'Q1': 'Y',
- 'Q2': ' Yes ',
- 'Q3': 'N',
- 'Q4': 'N ',
- }
- qs.term_input = mock_input(answers)
- qs.do_prompt(d, 'k1', 'Q1')
- assert d['k1'] == 'Y'
- qs.do_prompt(d, 'k2', 'Q2')
- assert d['k2'] == 'Yes'
- qs.do_prompt(d, 'k3', 'Q3')
- assert d['k3'] == 'N'
- qs.do_prompt(d, 'k4', 'Q4')
- assert d['k4'] == 'N'
-
-
def test_do_prompt():
- d = {}
answers = {
'Q2': 'v2',
'Q3': 'v3',
@@ -92,39 +70,43 @@ def test_do_prompt():
'Q6': 'foo',
}
qs.term_input = mock_input(answers)
- try:
- qs.do_prompt(d, 'k1', 'Q1')
- except AssertionError:
- assert 'k1' not in d
- else:
- assert False, 'AssertionError not raised'
- qs.do_prompt(d, 'k1', 'Q1', default='v1')
- assert d['k1'] == 'v1'
- qs.do_prompt(d, 'k3', 'Q3', default='v3_default')
- assert d['k3'] == 'v3'
- qs.do_prompt(d, 'k2', 'Q2')
- assert d['k2'] == 'v2'
- qs.do_prompt(d, 'k4', 'Q4', validator=qs.boolean)
- assert d['k4'] is True
- qs.do_prompt(d, 'k5', 'Q5', validator=qs.boolean)
- assert d['k5'] is False
+
+ assert qs.do_prompt('Q1', default='v1') == 'v1'
+ assert qs.do_prompt('Q3', default='v3_default') == 'v3'
+ assert qs.do_prompt('Q2') == 'v2'
+ assert qs.do_prompt('Q4', validator=qs.boolean) is True
+ assert qs.do_prompt('Q5', validator=qs.boolean) is False
with pytest.raises(AssertionError):
- qs.do_prompt(d, 'k6', 'Q6', validator=qs.boolean)
+ qs.do_prompt('Q6', validator=qs.boolean)
+
+
+def test_do_prompt_inputstrip():
+ answers = {
+ 'Q1': 'Y',
+ 'Q2': ' Yes ',
+ 'Q3': 'N',
+ 'Q4': 'N ',
+ }
+ qs.term_input = mock_input(answers)
+
+ assert qs.do_prompt('Q1') == 'Y'
+ assert qs.do_prompt('Q2') == 'Yes'
+ assert qs.do_prompt('Q3') == 'N'
+ assert qs.do_prompt('Q4') == 'N'
def test_do_prompt_with_nonascii():
- d = {}
answers = {
'Q1': u'\u30c9\u30a4\u30c4',
}
qs.term_input = mock_input(answers)
try:
- qs.do_prompt(d, 'k1', 'Q1', default=u'\u65e5\u672c')
+ result = qs.do_prompt('Q1', default=u'\u65e5\u672c')
except UnicodeEncodeError:
- raise SkipTest(
+ raise pytest.skip.Exception(
'non-ASCII console input not supported on this encoding: %s',
qs.TERM_ENCODING)
- assert d['k1'] == u'\u30c9\u30a4\u30c4'
+ assert result == u'\u30c9\u30a4\u30c4'
def test_quickstart_defaults(tempdir):
@@ -151,7 +133,6 @@ def test_quickstart_defaults(tempdir):
assert ns['copyright'] == '%s, Georg Brandl' % time.strftime('%Y')
assert ns['version'] == '0.1'
assert ns['release'] == '0.1'
- assert ns['todo_include_todos'] is False
assert ns['html_static_path'] == ['_static']
assert ns['latex_documents'] == [
('index', 'SphinxTest.tex', 'Sphinx Test Documentation',
@@ -298,8 +279,7 @@ def test_default_filename(tempdir):
def test_extensions(tempdir):
- qs.main(['sphinx-quickstart', '-q',
- '-p', 'project_name', '-a', 'author',
+ qs.main(['-q', '-p', 'project_name', '-a', 'author',
'--extensions', 'foo,bar,baz', tempdir])
conffile = tempdir / 'conf.py'