Add some tests for docfields.

This commit is contained in:
Georg Brandl
2010-07-27 19:19:29 +02:00
parent e081cf4d3b
commit 5a28ae4686
2 changed files with 21 additions and 2 deletions

View File

@@ -43,6 +43,11 @@ Testing object descriptions
.. class:: TimeInt
:param moo: |test|
:type moo: |test|
.. |test| replace:: Moo
.. class:: Time(hour, minute, isdst)
:param hour: The year.

View File

@@ -36,9 +36,9 @@ ENV_WARNINGS = """\
http://www.python.org/logo.png
%(root)s/includes.txt:\\d*: \\(WARNING/2\\) Encoding 'utf-8-sig' used for \
reading included file u'wrongenc.inc' seems to be wrong, try giving an \
:encoding: option\n?
:encoding: option\\n?
%(root)s/includes.txt:4: WARNING: download file not readable: nonexisting.png
%(root)s/objects.txt:79: WARNING: using old C markup; please migrate to \
%(root)s/objects.txt:84: WARNING: using old C markup; please migrate to \
new-style markup \(e.g. c:function instead of cfunction\), see \
http://sphinx.pocoo.org/domains.html
"""
@@ -50,6 +50,16 @@ HTML_WARNINGS = ENV_WARNINGS + """\
%(root)s/markup.txt:: WARNING: invalid pair index entry u'keyword; '
"""
def tail_check(check):
rex = re.compile(check)
def checker(nodes):
for node in nodes:
if node.tail and rex.search(node.tail):
return True
assert False, '%r not found in tail of any nodes %s' % (check, nodes)
return checker
HTML_XPATH = {
'images.html': [
(".//img[@src='_images/img.png']", ''),
@@ -171,6 +181,10 @@ HTML_XPATH = {
'Testing various markup'),
# custom sidebar
(".//h4", 'Custom sidebar'),
# docfields
(".//td[@class='field-body']/ul/li/strong", '^moo$'),
(".//td[@class='field-body']/ul/li/strong",
tail_check(r'\(Moo\) .* Moo')),
],
'contents.html': [
(".//meta[@name='hc'][@content='hcval']", ''),