diff options
Diffstat (limited to '')
-rw-r--r-- | tests/test_builders/test_build_epub.py (renamed from tests/test_build_epub.py) | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/tests/test_build_epub.py b/tests/test_builders/test_build_epub.py index 7f5b815..6829f22 100644 --- a/tests/test_build_epub.py +++ b/tests/test_builders/test_build_epub.py @@ -22,6 +22,7 @@ def runnable(command): class EPUBElementTree: """Test helper for content.opf and toc.ncx""" + namespaces = { 'idpf': 'http://www.idpf.org/2007/opf', 'dc': 'http://purl.org/dc/elements/1.1/', @@ -60,7 +61,7 @@ class EPUBElementTree: @pytest.mark.sphinx('epub', testroot='basic') def test_build_epub(app): - app.builder.build_all() + app.build(force_all=True) assert (app.outdir / 'mimetype').read_text(encoding='utf8') == 'application/epub+zip' assert (app.outdir / 'META-INF' / 'container.xml').exists() @@ -277,7 +278,7 @@ def test_escaped_toc(app): @pytest.mark.sphinx('epub', testroot='basic') def test_epub_writing_mode(app): # horizontal (default) - app.builder.build_all() + app.build(force_all=True) # horizontal / page-progression-direction opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text(encoding='utf8')) @@ -323,7 +324,7 @@ def test_epub_anchor_id(app): @pytest.mark.sphinx('epub', testroot='html_assets') def test_epub_assets(app): - app.builder.build_all() + app.build(force_all=True) # epub_sytlesheets (same as html_css_files) content = (app.outdir / 'index.xhtml').read_text(encoding='utf8') @@ -336,7 +337,7 @@ def test_epub_assets(app): @pytest.mark.sphinx('epub', testroot='html_assets', confoverrides={'epub_css_files': ['css/epub.css']}) def test_epub_css_files(app): - app.builder.build_all() + app.build(force_all=True) # epub_css_files content = (app.outdir / 'index.xhtml').read_text(encoding='utf8') @@ -361,13 +362,13 @@ def test_html_download_role(app, status, warning): '<span class="pre">not_found.dat</span></code></p></li>' in content) assert ('<li><p><code class="xref download docutils literal notranslate">' '<span class="pre">Sphinx</span> <span class="pre">logo</span></code>' - '<span class="link-target"> [http://www.sphinx-doc.org/en/master' - '/_static/sphinxheader.png]</span></p></li>' in content) + '<span class="link-target"> [https://www.sphinx-doc.org/en/master' + '/_static/sphinx-logo.svg]</span></p></li>' in content) @pytest.mark.sphinx('epub', testroot='toctree-duplicated') def test_duplicated_toctree_entry(app, status, warning): - app.builder.build_all() + app.build(force_all=True) assert 'WARNING: duplicated ToC entry found: foo.xhtml' in warning.getvalue() @@ -377,16 +378,21 @@ def test_duplicated_toctree_entry(app, status, warning): def test_run_epubcheck(app): app.build() + if not runnable(['java', '-version']): + pytest.skip("Unable to run Java; skipping test") + epubcheck = os.environ.get('EPUBCHECK_PATH', '/usr/share/java/epubcheck.jar') - if runnable(['java', '-version']) and os.path.exists(epubcheck): - try: - subprocess.run(['java', '-jar', epubcheck, app.outdir / 'SphinxTests.epub'], - capture_output=True, check=True) - except CalledProcessError as exc: - print(exc.stdout.decode('utf-8')) - print(exc.stderr.decode('utf-8')) - msg = f'epubcheck exited with return code {exc.returncode}' - raise AssertionError(msg) from exc + if not os.path.exists(epubcheck): + pytest.skip("Could not find epubcheck; skipping test") + + try: + subprocess.run(['java', '-jar', epubcheck, app.outdir / 'SphinxTests.epub'], + capture_output=True, check=True) + except CalledProcessError as exc: + print(exc.stdout.decode('utf-8')) + print(exc.stderr.decode('utf-8')) + msg = f'epubcheck exited with return code {exc.returncode}' + raise AssertionError(msg) from exc def test_xml_name_pattern_check(): |