mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix test: NamedTemporaryFile causes errors on Windows
This commit is contained in:
parent
38483a5e79
commit
01ccbbcccf
@ -15,28 +15,26 @@ from sphinx.util import logging
|
|||||||
from sphinx.util.pycompat import execfile_
|
from sphinx.util.pycompat import execfile_
|
||||||
|
|
||||||
|
|
||||||
def test_execfile_python2(capsys, app, status, warning):
|
def test_execfile_python2(capsys, app, status, warning, tempdir):
|
||||||
logging.setup(app, status, warning)
|
logging.setup(app, status, warning)
|
||||||
|
|
||||||
ns = {}
|
conf_py = tempdir / 'conf.py'
|
||||||
with tempfile.NamedTemporaryFile() as tmp:
|
conf_py.write_bytes(b'print "hello"\n')
|
||||||
tmp.write(b'print "hello"\n')
|
execfile_(conf_py, {})
|
||||||
tmp.flush()
|
|
||||||
execfile_(tmp.name, ns)
|
|
||||||
msg = (
|
msg = (
|
||||||
'Support for evaluating Python 2 syntax is deprecated '
|
'Support for evaluating Python 2 syntax is deprecated '
|
||||||
'and will be removed in Sphinx 4.0. '
|
'and will be removed in Sphinx 4.0. '
|
||||||
'Convert %s to Python 3 syntax.\n' % tmp.name)
|
'Convert %s to Python 3 syntax.\n' % conf_py)
|
||||||
assert msg in strip_escseq(warning.getvalue())
|
assert msg in strip_escseq(warning.getvalue())
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert captured.out == 'hello\n'
|
assert captured.out == 'hello\n'
|
||||||
|
|
||||||
|
|
||||||
def test_execfile(capsys):
|
def test_execfile(capsys, tempdir):
|
||||||
ns = {}
|
conf_py = tempdir / 'conf.py'
|
||||||
with tempfile.NamedTemporaryFile() as tmp:
|
conf_py.write_bytes(b'print("hello")\n')
|
||||||
tmp.write(b'print("hello")\n')
|
execfile_(conf_py, {})
|
||||||
tmp.flush()
|
|
||||||
execfile_(tmp.name, ns)
|
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert captured.out == 'hello\n'
|
assert captured.out == 'hello\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user