conf.py now accept CRLF end-of-line.

This commit is contained in:
Takayuki Shimizukawa
2013-02-10 15:25:45 +09:00
parent 57a84ff442
commit 05718e4a1a
4 changed files with 47 additions and 34 deletions

View File

@@ -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'

View File

@@ -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'