summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-02-19 23:31:35 +0900
committerGitHub <noreply@github.com>2018-02-19 23:31:35 +0900
commitd2b2cefe6980c54be59fe35e269d3a53325a7075 (patch)
tree7803ea25d5271e3610ea31728bc29c009224c738
parent82c320ac2964c6ece0f4bbacf619e3c4454e26e7 (diff)
parent2523979d26124475b218510d2de98616c7eebb3a (diff)
downloadsphinx-git-d2b2cefe6980c54be59fe35e269d3a53325a7075.tar.gz
Merge pull request #4642 from tk0miya/4611_epubcheck
test: Run epubcheck as a testing
-rw-r--r--tests/test_build.py4
-rw-r--r--tests/test_build_epub.py29
2 files changed, 31 insertions, 2 deletions
diff --git a/tests/test_build.py b/tests/test_build.py
index df0458aa3..30237c2e0 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -60,13 +60,13 @@ def nonascii_srcdir(request, rootdir, sphinx_test_tempdir):
# note: this test skips building docs for some builders because they have independent testcase.
-# (html, latex, texinfo and manpage)
+# (html, epub, latex, texinfo and manpage)
@pytest.mark.parametrize(
"buildername",
[
# note: no 'html' - if it's ok with dirhtml it's ok with html
'dirhtml', 'singlehtml', 'pickle', 'json', 'text', 'htmlhelp', 'qthelp',
- 'epub', 'applehelp', 'changes', 'xml', 'pseudoxml', 'linkcheck',
+ 'applehelp', 'changes', 'xml', 'pseudoxml', 'linkcheck',
],
)
@mock.patch('sphinx.builders.linkcheck.requests.head',
diff --git a/tests/test_build_epub.py b/tests/test_build_epub.py
index e5d86b0ed..ef2e4d87d 100644
--- a/tests/test_build_epub.py
+++ b/tests/test_build_epub.py
@@ -9,11 +9,25 @@
:license: BSD, see LICENSE for details.
"""
+import os
+from subprocess import Popen, PIPE
from xml.etree import ElementTree
import pytest
+# check given command is runnable
+def runnable(command):
+ try:
+ p = Popen(command, stdout=PIPE)
+ except OSError:
+ # command not found
+ return False
+ else:
+ p.communicate()
+ return p.returncode
+
+
class EPUBElementTree(object):
"""Test helper for content.opf and tox.ncx"""
namespaces = {
@@ -245,3 +259,18 @@ def test_epub_writing_mode(app):
# vertical / writing-mode (CSS)
css = (app.outdir / '_static' / 'epub.css').text()
assert 'writing-mode: vertical-rl;' in css
+
+
+@pytest.mark.sphinx('epub')
+def test_run_epubcheck(app):
+ app.build()
+
+ epubcheck = os.environ.get('EPUBCHECK_PATH', '/usr/share/java/epubcheck.jar')
+ if runnable('java') and os.path.exists(epubcheck):
+ p = Popen(['java', '-jar', epubcheck, app.outdir / 'Sphinx.epub'],
+ stdout=PIPE, stderr=PIPE)
+ stdout, stderr = p.communicate()
+ if p.returncode != 0:
+ print(stdout)
+ print(stderr)
+ assert False, 'epubcheck exited with return code %s' % p.returncode