Merge pull request #5860 from animalize/fix_test

don't generate build files inside /tests/roots/test-build-htmlhelp/
This commit is contained in:
Takeshi KOMIYA 2018-12-23 23:51:06 +09:00 committed by GitHub
commit 503cf9c39e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,39 +6,20 @@
:license: BSD, see LICENSE for details.
"""
import os.path
import re
import sys
from subprocess import Popen, PIPE
import pytest
from sphinx.util.osutil import cd
@pytest.mark.skipif(sys.platform != "win32",
reason="hhc.exe only available on Windows.")
@pytest.mark.sphinx('htmlhelp', testroot='build-htmlhelp')
def test_chm():
# run make.bat
with cd(r".\roots\test-build-htmlhelp"):
try:
p = Popen(['make.bat'],
stdout=PIPE, stderr=PIPE)
except:
raise
else:
p.communicate()
def test_chm(app):
app.build()
# check .hhk file
this_path = os.path.dirname(os.path.abspath(__file__))
hhk_file = os.path.join(this_path, 'roots', 'test-build-htmlhelp',
'build', 'htmlhelp', 'test.hhk')
if not os.path.isfile(hhk_file):
print(".chm build failed, please install HTML Help Workshop.")
return
outname = app.builder.config.htmlhelp_basename
hhk_path = str(app.outdir / outname + '.hhk')
with open(hhk_file, 'rb') as f:
with open(hhk_path, 'rb') as f:
data = f.read()
m = re.search(br'&#[xX][0-9a-fA-F]+;', data)
assert m == None, 'Hex escaping exists in .hhk file: ' + str(m.group(0))