summaryrefslogtreecommitdiff
path: root/tests/test_build_htmlhelp.py
diff options
context:
space:
mode:
authoranimalize <animalize@users.noreply.github.com>2018-12-23 21:39:12 +0800
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-12-23 22:39:12 +0900
commitcedd94c541c242c94e806def7b782521577cda48 (patch)
tree69efab0e73e2767d69920c06286e7868c272f4ef /tests/test_build_htmlhelp.py
parenta77f344035b3cb18b9fe9a06e41059c654c7dafe (diff)
downloadsphinx-git-cedd94c541c242c94e806def7b782521577cda48.tar.gz
[1.8] htmlhelp: convert hex escaping to decimal escaping in .hhc/.hhk files (#5853)
* htmlhelp: convert hex escaping to decimal escaping in .hhc/.hhk files .hhc/.hhk files don't recognize hex escaping, we need convert hex escaping to decimal escaping. for example: `&#x27;` -> `&#39;`.
Diffstat (limited to 'tests/test_build_htmlhelp.py')
-rw-r--r--tests/test_build_htmlhelp.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_build_htmlhelp.py b/tests/test_build_htmlhelp.py
new file mode 100644
index 000000000..5a47ca580
--- /dev/null
+++ b/tests/test_build_htmlhelp.py
@@ -0,0 +1,45 @@
+"""
+ test_build_htmlhelp
+ ~~~~~~~~~~~~~~~~~~~
+ Test the HTML Help builder and check output against XPath.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
+ :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()
+
+ # 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
+
+ with open(hhk_file, '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))
+