2015-01-15 07:17:01 -06:00
|
|
|
# -*- 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`.
|
|
|
|
|
2019-01-02 01:00:30 -06:00
|
|
|
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
2015-01-15 07:17:01 -06:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import plistlib
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
import pytest
|
2018-02-19 07:39:14 -06:00
|
|
|
|
2017-05-07 02:46:44 -05:00
|
|
|
from sphinx.testing.path import path
|
2015-01-15 07:17:01 -06:00
|
|
|
|
|
|
|
# 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()
|
|
|
|
|
2015-01-15 07:40:37 -06:00
|
|
|
with open(contentsdir / 'Info.plist', 'rb') as f:
|
2015-01-15 07:17:01 -06:00
|
|
|
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()
|
|
|
|
|
2015-03-09 10:22:02 -05:00
|
|
|
|
2015-01-15 07:17:01 -06:00
|
|
|
def check_localization(outdir):
|
|
|
|
lprojdir = outdir / 'Contents' / 'Resources' / 'en.lproj'
|
|
|
|
assert (lprojdir / 'localized.txt').isfile()
|
|
|
|
|
2015-03-09 10:22:02 -05:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'applehelp', testroot='basic', srcdir='applehelp_output',
|
|
|
|
confoverrides={'applehelp_bundle_id': 'org.sphinx-doc.Sphinx.help',
|
|
|
|
'applehelp_disable_external_tools': True})
|
2015-01-15 07:17:01 -06:00
|
|
|
def test_applehelp_output(app, status, warning):
|
2016-07-13 19:41:46 -05:00
|
|
|
(app.srcdir / 'en.lproj').makedirs()
|
|
|
|
(app.srcdir / 'en.lproj' / 'localized.txt').write_text('')
|
2015-01-15 07:17:01 -06:00
|
|
|
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)
|