mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
conf.py now accept CRLF end-of-line.
This commit is contained in:
@@ -16,6 +16,7 @@ from util import *
|
||||
import sphinx
|
||||
from sphinx.config import Config
|
||||
from sphinx.errors import ExtensionError, ConfigError, VersionRequirementError
|
||||
from sphinx.util.pycompat import b
|
||||
|
||||
|
||||
@with_app(confoverrides={'master_doc': 'master', 'nonexisting_value': 'True',
|
||||
@@ -113,3 +114,14 @@ def test_errors_warnings(dir):
|
||||
def test_needs_sphinx():
|
||||
raises(VersionRequirementError, TestApp,
|
||||
confoverrides={'needs_sphinx': '9.9'})
|
||||
|
||||
|
||||
@with_tempdir
|
||||
def test_config_eol(tmpdir):
|
||||
# test config file's eol patterns: LF, CRLF
|
||||
configfile = tmpdir / 'conf.py'
|
||||
for eol in ('\n', '\r\n'):
|
||||
configfile.write_bytes(b('project = "spam"' + eol))
|
||||
cfg = Config(tmpdir, 'conf.py', {}, None)
|
||||
cfg.init_values()
|
||||
assert cfg.project == u'spam'
|
||||
|
||||
@@ -16,6 +16,7 @@ from util import *
|
||||
|
||||
from sphinx import quickstart as qs
|
||||
from sphinx.util.console import nocolor, coloron
|
||||
from sphinx.util.pycompat import execfile_
|
||||
|
||||
def setup_module():
|
||||
nocolor()
|
||||
@@ -110,12 +111,7 @@ def test_quickstart_defaults(tempdir):
|
||||
conffile = tempdir / 'conf.py'
|
||||
assert conffile.isfile()
|
||||
ns = {}
|
||||
f = open(conffile, 'rbU')
|
||||
try:
|
||||
code = compile(f.read(), conffile, 'exec')
|
||||
finally:
|
||||
f.close()
|
||||
exec code in ns
|
||||
execfile_(conffile, ns)
|
||||
assert ns['extensions'] == []
|
||||
assert ns['templates_path'] == ['_templates']
|
||||
assert ns['source_suffix'] == '.rst'
|
||||
@@ -170,12 +166,7 @@ def test_quickstart_all_answers(tempdir):
|
||||
conffile = tempdir / 'source' / 'conf.py'
|
||||
assert conffile.isfile()
|
||||
ns = {}
|
||||
f = open(conffile, 'rbU')
|
||||
try:
|
||||
code = compile(f.read(), conffile, 'exec')
|
||||
finally:
|
||||
f.close()
|
||||
exec code in ns
|
||||
execfile_(conffile, ns)
|
||||
assert ns['extensions'] == ['sphinx.ext.autodoc', 'sphinx.ext.doctest']
|
||||
assert ns['templates_path'] == ['.templates']
|
||||
assert ns['source_suffix'] == '.txt'
|
||||
|
||||
Reference in New Issue
Block a user