mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #4642 from tk0miya/4611_epubcheck
test: Run epubcheck as a testing
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user