diff --git a/tests/root/conf.py b/tests/root/conf.py index 5186f3715..76cfedd60 100644 --- a/tests/root/conf.py +++ b/tests/root/conf.py @@ -42,6 +42,9 @@ html_context = {'hckey': 'hcval', 'hckey_co': 'wrong_hcval_co'} htmlhelp_basename = 'SphinxTestsdoc' +applehelp_bundle_id = 'org.sphinx-doc.Sphinx.help' +applehelp_disable_external_tools = True + latex_documents = [ ('contents', 'SphinxTests.tex', 'Sphinx Tests Documentation', 'Georg Brandl \\and someone else', 'manual'), diff --git a/tests/root/en.lproj/localized.txt b/tests/root/en.lproj/localized.txt new file mode 100644 index 000000000..20e1b2b05 --- /dev/null +++ b/tests/root/en.lproj/localized.txt @@ -0,0 +1,2 @@ +This file should be included in the final bundle by the applehelp builder. +It should be ignored by other builders. diff --git a/tests/test_build.py b/tests/test_build.py index 5aec0d3d8..ed39f6971 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -66,9 +66,10 @@ def test_build_all(): ).encode('utf-8')) # note: no 'html' - if it's ok with dirhtml it's ok with html - for buildername in ['dirhtml', 'singlehtml', 'latex', 'texinfo', - 'pickle', 'json', 'text', 'htmlhelp', 'qthelp', 'epub', - 'changes', 'xml', 'pseudoxml', 'man', 'linkcheck']: + for buildername in ['dirhtml', 'singlehtml', 'latex', 'texinfo', 'pickle', + 'json', 'text', 'htmlhelp', 'qthelp', 'epub', + 'applehelp', 'changes', 'xml', 'pseudoxml', 'man', + 'linkcheck']: yield verify_build, buildername, srcdir diff --git a/tests/test_build_applehelp.py b/tests/test_build_applehelp.py new file mode 100644 index 000000000..258b56773 --- /dev/null +++ b/tests/test_build_applehelp.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +""" + test_build_applehelp + ~~~~~~~~~~~~~~~~~~~~ + + Test the Apple Help builder and check its output. We don't need to + test the HTML itself; that's already handled by + :file:`test_build_html.py`. + + :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import os +import plistlib + +from util import with_app +from path import path + +# Use plistlib.load in 3.4 and above +try: + read_plist = plistlib.load +except AttributeError: + read_plist = plistlib.readPlist + + +def check_structure(outdir): + contentsdir = outdir / 'Contents' + assert contentsdir.isdir() + assert (contentsdir / 'Info.plist').isfile() + + with open(contentsdir / 'Info.plist', 'r') as f: + plist = read_plist(f) + assert plist + assert len(plist) + assert plist.get('CFBundleIdentifier', None) == 'org.sphinx-doc.Sphinx.help' + + assert (contentsdir / 'Resources').isdir() + assert (contentsdir / 'Resources' / 'en.lproj').isdir() + + +def check_localization(outdir): + lprojdir = outdir / 'Contents' / 'Resources' / 'en.lproj' + assert (lprojdir / 'localized.txt').isfile() + + +@with_app(buildername='applehelp') +def test_applehelp_output(app, status, warning): + app.builder.build_all() + + # Have to use bundle_path, not outdir, because we alter the latter + # to point to the lproj directory so that the HTML arrives in the + # correct location. + bundle_path = path(app.builder.bundle_path) + check_structure(bundle_path) + check_localization(bundle_path)