#! /usr/bin/env python # $Id: test_field_lists.py 4564 2006-05-21 20:44:42Z wiemann $ # Author: David Goodger # Copyright: This module has been placed in the public domain. """ Tests for states.py. """ from .__init__ import DocutilsTestSupport def suite(): s = DocutilsTestSupport.ParserTestSuite() s.generateTests(totest) return s totest = {} totest['field_lists'] = [ ["""\ One-liners: :Author: Me :Version: 1 :Date: 2001-08-11 :Parameter i: integer """, """\ One-liners: Author Me Version 1 Date 2001-08-11 Parameter i integer """], ["""\ One-liners, no blank lines: :Author: Me :Version: 1 :Date: 2001-08-11 :Parameter i: integer """, """\ One-liners, no blank lines: Author Me Version 1 Date 2001-08-11 Parameter i integer """], ["""\ :field: empty item above, no blank line """, """\ field Field list ends without a blank line; unexpected unindent. empty item above, no blank line """], ["""\ Field bodies starting on the next line: :Author: Me :Version: 1 :Date: 2001-08-11 :Parameter i: integer """, """\ Field bodies starting on the next line: Author Me Version 1 Date 2001-08-11 Parameter i integer """], ["""\ One-paragraph, multi-liners: :Authors: Me, Myself, and I :Version: 1 or so :Date: 2001-08-11 (Saturday) :Parameter i: counter (integer) """, """\ One-paragraph, multi-liners: Authors Me, Myself, and I Version 1 or so Date 2001-08-11 (Saturday) Parameter i counter (integer) """], ["""\ One-paragraph, multi-liners, not lined up: :Authors: Me, Myself, and I :Version: 1 or so :Date: 2001-08-11 (Saturday) :Parameter i: counter (integer) """, """\ One-paragraph, multi-liners, not lined up: Authors Me, Myself, and I Version 1 or so Date 2001-08-11 (Saturday) Parameter i counter (integer) """], ["""\ Multiple body elements: :Authors: - Me - Myself - I :Abstract: This is a field list item's body, containing multiple elements. Here's a literal block:: def f(x): return x**2 + x Even nested field lists are possible: :Date: 2001-08-11 :Day: Saturday :Time: 15:07 """, """\ Multiple body elements: Authors Me Myself I Abstract This is a field list item's body, containing multiple elements. Here's a literal block: def f(x): return x**2 + x Even nested field lists are possible: Date 2001-08-11 Day Saturday Time 15:07 """], ["""\ Nested field lists on one line: :field1: :field2: :field3: body :field4: :field5: :field6: body :field7: body :field8: body :field9: body line 1 body line 2 """, """\ Nested field lists on one line: field1 field2 field3 body field4 field5 field6 body field7 body field8 body field9 body line 1 body line 2 """], ["""\ :Parameter i j k: multiple arguments """, """\ Parameter i j k multiple arguments """], ["""\ :Field *name* `with` **inline** ``markup``: inline markup in field name is parsed. """, """\ Field \n\ name \n\ with \n\ inline \n\ markup inline markup in field name is parsed. """], ["""\ :Field name with *bad inline markup: should generate warning. """, """\ Field name with \n\ * bad inline markup Inline emphasis start-string without end-string. should generate warning. """], [r"""Some edge cases: :Empty: :Author: Me No blank line before this paragraph. : Field: marker must not begin with whitespace. :Field : marker must not end with whitespace. Field: marker is missing its open-colon. :Field marker is missing its close-colon. :Field\: names\: with\: colons\:: are possible. :\\Field\ names with backslashes\\: are possible, too. :\\: A backslash. :Not a\\\: field list. :Not a \: field list either. :\: Not a field list either. :\: A definition list, not a field list. """, """\ Some edge cases: Empty Author Me Field list ends without a blank line; unexpected unindent. No blank line before this paragraph. : Field: marker must not begin with whitespace. :Field : marker must not end with whitespace. Field: marker is missing its open-colon. :Field marker is missing its close-colon. Field: names: with: colons: are possible. \\Field names with backslashes\\ are possible, too. \\ A backslash. :Not a\\: field list. :Not a : field list either. :: Not a field list either. :: A definition list, not a field list. """], ] if __name__ == '__main__': import unittest unittest.main(defaultTest='suite')