Skip to content

Commit 5695b76

Browse files
jayaddisonpicnixz
andauthored
[tests] epub: skip the epubcheck test if Java or epubcheck itself are not found (#12098)
Co-authored-by: Bénédikt Tran <[email protected]>
1 parent 768cf5e commit 5695b76

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ Bugs fixed
102102
Testing
103103
-------
104104

105+
* pytest: report the result of ``test_run_epubcheck`` as ``skipped`` instead of
106+
``success`` when Java and/or the ``epubcheck.jar`` code are not available.
107+
105108
Release 7.2.6 (released Sep 13, 2023)
106109
=====================================
107110

tests/test_builders/test_build_epub.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,16 +378,21 @@ def test_duplicated_toctree_entry(app, status, warning):
378378
def test_run_epubcheck(app):
379379
app.build()
380380

381+
if not runnable(['java', '-version']):
382+
pytest.skip("Unable to run Java; skipping test")
383+
381384
epubcheck = os.environ.get('EPUBCHECK_PATH', '/usr/share/java/epubcheck.jar')
382-
if runnable(['java', '-version']) and os.path.exists(epubcheck):
383-
try:
384-
subprocess.run(['java', '-jar', epubcheck, app.outdir / 'SphinxTests.epub'],
385-
capture_output=True, check=True)
386-
except CalledProcessError as exc:
387-
print(exc.stdout.decode('utf-8'))
388-
print(exc.stderr.decode('utf-8'))
389-
msg = f'epubcheck exited with return code {exc.returncode}'
390-
raise AssertionError(msg) from exc
385+
if not os.path.exists(epubcheck):
386+
pytest.skip("Could not find epubcheck; skipping test")
387+
388+
try:
389+
subprocess.run(['java', '-jar', epubcheck, app.outdir / 'SphinxTests.epub'],
390+
capture_output=True, check=True)
391+
except CalledProcessError as exc:
392+
print(exc.stdout.decode('utf-8'))
393+
print(exc.stderr.decode('utf-8'))
394+
msg = f'epubcheck exited with return code {exc.returncode}'
395+
raise AssertionError(msg) from exc
391396

392397

393398
def test_xml_name_pattern_check():

0 commit comments

Comments
 (0)