Commits

Georg Brandl committed 2f12a74

Add some tests for docfields.

  • Participants
  • Parent commits 523ef8a

Comments (0)

Files changed (2)

File tests/root/objects.txt

 
 .. class:: TimeInt
 
+   :param moo: |test|
+   :type moo: |test|
+
+.. |test| replace:: Moo
+
 .. class:: Time(hour, minute, isdst)
 
    :param hour: The year.

File tests/test_build_html.py

 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
 """
 %(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']", ''),
             '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']", ''),