diff options
author | Georg Brandl <georg@python.org> | 2015-03-08 15:35:04 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2015-03-08 15:35:04 +0100 |
commit | 705f6a997bf622cdc95f80868d0fd0a703124b1d (patch) | |
tree | a33a6cb96f3dd9e2a06e42d98f2aace20f54b23e /tests/test_build_applehelp.py | |
parent | f2267942f3e4ff9b33a7457af0d00b9841ec842b (diff) | |
parent | cc58f0a5e4804a0e5054d01bd07a76ed8ce17937 (diff) | |
download | sphinx-git-705f6a997bf622cdc95f80868d0fd0a703124b1d.tar.gz |
Merge branch 'apple-help' of git://github.com/al45tair/sphinx
Diffstat (limited to 'tests/test_build_applehelp.py')
-rw-r--r-- | tests/test_build_applehelp.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test_build_applehelp.py b/tests/test_build_applehelp.py new file mode 100644 index 000000000..8d778f78f --- /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', 'rb') 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) |