diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-01-13 17:43:11 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-01-13 17:43:11 +0900 |
commit | 01ccbbcccf125143ef0ffe4d7cfea71328d0a70c (patch) | |
tree | 4c7109af26ba611b130c85c9f34ce04a800bf65c /tests/test_util_pycompat.py | |
parent | 38483a5e7975807f605404886b59ae3df0dfa7fb (diff) | |
download | sphinx-git-01ccbbcccf125143ef0ffe4d7cfea71328d0a70c.tar.gz |
Fix test: NamedTemporaryFile causes errors on Windows
Diffstat (limited to 'tests/test_util_pycompat.py')
-rw-r--r-- | tests/test_util_pycompat.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/tests/test_util_pycompat.py b/tests/test_util_pycompat.py index a815d1c4f..6ffc83f84 100644 --- a/tests/test_util_pycompat.py +++ b/tests/test_util_pycompat.py @@ -15,28 +15,26 @@ from sphinx.util import logging 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) - ns = {} - with tempfile.NamedTemporaryFile() as tmp: - tmp.write(b'print "hello"\n') - tmp.flush() - execfile_(tmp.name, ns) + conf_py = tempdir / 'conf.py' + conf_py.write_bytes(b'print "hello"\n') + execfile_(conf_py, {}) + msg = ( 'Support for evaluating Python 2 syntax is deprecated ' '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()) captured = capsys.readouterr() assert captured.out == 'hello\n' -def test_execfile(capsys): - ns = {} - with tempfile.NamedTemporaryFile() as tmp: - tmp.write(b'print("hello")\n') - tmp.flush() - execfile_(tmp.name, ns) +def test_execfile(capsys, tempdir): + conf_py = tempdir / 'conf.py' + conf_py.write_bytes(b'print("hello")\n') + execfile_(conf_py, {}) + captured = capsys.readouterr() assert captured.out == 'hello\n' |