2009-12-21 06:24:33 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_metadata
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test our ahndling of metadata in files with bibliographic metadata
|
|
|
|
|
|
|
|
:copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
|
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# adapted from an example of bibliographic metadata at http://docutils.sourceforge.net/docs/user/rst/demo.txt
|
|
|
|
|
|
|
|
from util import *
|
|
|
|
|
2009-12-21 07:06:25 -06:00
|
|
|
from nose.tools import assert_equals
|
|
|
|
|
2009-12-21 06:40:44 -06:00
|
|
|
from sphinx.environment import BuildEnvironment
|
|
|
|
from sphinx.builders.html import StandaloneHTMLBuilder
|
|
|
|
from sphinx.builders.latex import LaTeXBuilder
|
2009-12-21 06:24:33 -06:00
|
|
|
|
2009-12-21 06:40:44 -06:00
|
|
|
app = env = None
|
|
|
|
warnings = []
|
2009-12-21 06:24:33 -06:00
|
|
|
|
|
|
|
def setup_module():
|
2009-12-21 07:06:25 -06:00
|
|
|
# Is there a better way of generating this doctree than manually iterating?
|
2009-12-21 06:40:44 -06:00
|
|
|
global app, env
|
|
|
|
app = TestApp(srcdir='(temp)')
|
|
|
|
env = BuildEnvironment(app.srcdir, app.doctreedir, app.config)
|
2009-12-21 07:06:25 -06:00
|
|
|
# Huh. Why do I need to do this?
|
|
|
|
env.set_warnfunc(lambda *args: warnings.append(args))
|
2009-12-21 06:40:44 -06:00
|
|
|
msg, num, it = env.update(app.config, app.srcdir, app.doctreedir, app)
|
|
|
|
for docname in it:
|
|
|
|
pass
|
2009-12-21 06:24:33 -06:00
|
|
|
|
|
|
|
def teardown_module():
|
|
|
|
app.cleanup()
|
|
|
|
|
2009-12-21 07:06:25 -06:00
|
|
|
def test_docinfo():
|
|
|
|
exampledocinfo = env.metadata['metadata']
|
|
|
|
expected_metadata = {
|
|
|
|
'author': u'David Goodger',
|
|
|
|
u'field name': u'This is a generic bibliographic field.',
|
|
|
|
u'field name 2': u'Generic bibliographic fields may contain multiple body elements.\n\nLike this.'}
|
|
|
|
# I like this way of comparing dicts - easier to see the error.
|
|
|
|
for key in exampledocinfo:
|
|
|
|
yield assert_equals, exampledocinfo[key], expected_metadata[key]
|
|
|
|
#but then we still have to check for missing keys
|
2009-12-21 23:35:30 -06:00
|
|
|
yield assert_equals, set(expected_metadata.keys()), set(exampledocinfo.keys())
|