From 2703f7c25b10c10f59db93e0776cb81c1d181bca Mon Sep 17 00:00:00 2001 From: wiemann Date: Tue, 5 Jul 2005 20:29:55 +0000 Subject: moved transition transform logic from universal.FinalChecks to a separate transform, misc.Transitions git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3657 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_transforms/test_transitions.py | 308 +++++++++++++++++++++++++++++++ 1 file changed, 308 insertions(+) create mode 100755 test/test_transforms/test_transitions.py (limited to 'test/test_transforms/test_transitions.py') diff --git a/test/test_transforms/test_transitions.py b/test/test_transforms/test_transitions.py new file mode 100755 index 000000000..9711c4aee --- /dev/null +++ b/test/test_transforms/test_transitions.py @@ -0,0 +1,308 @@ +#! /usr/bin/env python + +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Test module for transforms/__init__.py. +""" + +from docutils.transforms.misc import Transitions +from __init__ import DocutilsTestSupport +from docutils.parsers.rst import Parser + +def suite(): + parser = Parser() + s = DocutilsTestSupport.TransformTestSuite(parser) + s.generateTests(totest) + return s + + +totest = {} + +totest['transitions'] = ((Transitions,), [ +["""\ +Section 1 +========= + +Subsection 1 +------------ + +Some text. + +---------- + +Section 2 +========= + +Some text. +""", +"""\ + +
+ + Section 1 + <section ids="subsection-1" names="subsection 1"> + <title> + Subsection 1 + <paragraph> + Some text. + <transition> + <section ids="section-2" names="section 2"> + <title> + Section 2 + <paragraph> + Some text. +"""], +["""\ +A paragraph. + +---------- + +Section 1 +========= + +Paragraph. +""", +"""\ +<document source="test data"> + <paragraph> + A paragraph. + <transition> + <section ids="section-1" names="section 1"> + <title> + Section 1 + <paragraph> + Paragraph. +"""], +["""\ +-------- + +A section or document may not begin with a transition. + +The DTD specifies that two transitions may not +be adjacent: + +-------- + +-------- + +-------- + +The DTD also specifies that a section or document +may not end with a transition. + +-------- +""", +"""\ +<document source="test data"> + <system_message level="3" line="1" source="test data" type="ERROR"> + <paragraph> + Document or section may not begin with a transition. + <transition> + <paragraph> + A section or document may not begin with a transition. + <paragraph> + The DTD specifies that two transitions may not + be adjacent: + <transition> + <system_message level="3" line="10" source="test data" type="ERROR"> + <paragraph> + At least one body element must separate transitions; adjacent transitions are not allowed. + <transition> + <system_message level="3" line="12" source="test data" type="ERROR"> + <paragraph> + At least one body element must separate transitions; adjacent transitions are not allowed. + <transition> + <paragraph> + The DTD also specifies that a section or document + may not end with a transition. + <transition> + <system_message level="3" line="17" source="test data" type="ERROR"> + <paragraph> + Document may not end with a transition. +"""], +["""\ +Sections with transitions at beginning and end. + +Section 1 +========= + +---------- + +The next transition is legal: + +---------- + +Section 2 +========= + +---------- +""", +"""\ +<document source="test data"> + <paragraph> + Sections with transitions at beginning and end. + <section ids="section-1" names="section 1"> + <title> + Section 1 + <system_message level="3" line="6" source="test data" type="ERROR"> + <paragraph> + Document or section may not begin with a transition. + <transition> + <paragraph> + The next transition is legal: + <transition> + <section ids="section-2" names="section 2"> + <title> + Section 2 + <system_message level="3" line="15" source="test data" type="ERROR"> + <paragraph> + Document or section may not begin with a transition. + <transition> + <system_message level="3" line="15" source="test data" type="ERROR"> + <paragraph> + Document may not end with a transition. +"""], +["""\ +A paragraph and two transitions. + +---------- + +---------- +""", # the same: +"""\ +<document source="test data"> + <paragraph> + A paragraph and two transitions. + <transition> + <system_message level="3" line="5" source="test data" type="ERROR"> + <paragraph> + At least one body element must separate transitions; adjacent transitions are not allowed. + <transition> + <system_message level="3" line="5" source="test data" type="ERROR"> + <paragraph> + Document may not end with a transition. +"""], +["""\ +A paragraph, two transitions, and a blank line. + +---------- + +---------- + +""", +"""\ +<document source="test data"> + <paragraph> + A paragraph, two transitions, and a blank line. + <transition> + <system_message level="3" line="5" source="test data" type="ERROR"> + <paragraph> + At least one body element must separate transitions; adjacent transitions are not allowed. + <transition> + <system_message level="3" line="5" source="test data" type="ERROR"> + <paragraph> + Document may not end with a transition. +"""], +["""\ +---------- + +Document beginning with a transition. +""", +"""\ +<document source="test data"> + <system_message level="3" line="1" source="test data" type="ERROR"> + <paragraph> + Document or section may not begin with a transition. + <transition> + <paragraph> + Document beginning with a transition. +"""], +["""\ +Section 1 +========= + +---------- + +---------- + +---------- + +Section 2 +========= + +Some text. +""", +"""\ +<document source="test data"> + <section ids="section-1" names="section 1"> + <title> + Section 1 + <system_message level="3" line="4" source="test data" type="ERROR"> + <paragraph> + Document or section may not begin with a transition. + <transition> + <system_message level="3" line="6" source="test data" type="ERROR"> + <paragraph> + At least one body element must separate transitions; adjacent transitions are not allowed. + <transition> + <system_message level="3" line="8" source="test data" type="ERROR"> + <paragraph> + At least one body element must separate transitions; adjacent transitions are not allowed. + <transition> + <section ids="section-2" names="section 2"> + <title> + Section 2 + <paragraph> + Some text. +"""], +["""\ +---------- + +---------- + +---------- +""", +"""\ +<document source="test data"> + <system_message level="3" line="1" source="test data" type="ERROR"> + <paragraph> + Document or section may not begin with a transition. + <transition> + <system_message level="3" line="3" source="test data" type="ERROR"> + <paragraph> + At least one body element must separate transitions; adjacent transitions are not allowed. + <transition> + <system_message level="3" line="5" source="test data" type="ERROR"> + <paragraph> + At least one body element must separate transitions; adjacent transitions are not allowed. + <transition> + <system_message level="3" line="5" source="test data" type="ERROR"> + <paragraph> + Document may not end with a transition. +"""], +["""\ +A paragraph. + +---------- + +""", +"""\ +<document source="test data"> + <paragraph> + A paragraph. + <transition> + <system_message level="3" line="3" source="test data" type="ERROR"> + <paragraph> + Document may not end with a transition. +"""], +]) + + +if __name__ == '__main__': + import unittest + unittest.main(defaultTest='suite') -- cgit v1.2.1 From e0a1eaac9d47da79a00c92c74ef7e789464421b7 Mon Sep 17 00:00:00 2001 From: wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> Date: Tue, 5 Jul 2005 23:14:55 +0000 Subject: moved expose_internals logic out of FinalChecks into a separate transform, universal.ExposeInternals git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3658 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_transforms/test_transitions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/test_transforms/test_transitions.py') diff --git a/test/test_transforms/test_transitions.py b/test/test_transforms/test_transitions.py index 9711c4aee..24a69bb52 100755 --- a/test/test_transforms/test_transitions.py +++ b/test/test_transforms/test_transitions.py @@ -7,7 +7,7 @@ # Copyright: This module has been placed in the public domain. """ -Test module for transforms/__init__.py. +Test module for misc.Transitions transform. """ from docutils.transforms.misc import Transitions -- cgit v1.2.1 From fa67b65d49e091aec810d2e5e8db5b19fc5be2d5 Mon Sep 17 00:00:00 2001 From: goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> Date: Sun, 2 Oct 2005 01:06:42 +0000 Subject: Added ``serial_escape`` function; escapes string values that are elements of a list, for serialization. Modified Docutils-XML writing (``Element._dom_node``) and pseudo-XML writing (``Element.starttag``) to use ``serial_escape``. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3915 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_transforms/test_transitions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/test_transforms/test_transitions.py') diff --git a/test/test_transforms/test_transitions.py b/test/test_transforms/test_transitions.py index 24a69bb52..e450ddff7 100755 --- a/test/test_transforms/test_transitions.py +++ b/test/test_transforms/test_transitions.py @@ -42,16 +42,16 @@ Some text. """, """\ <document source="test data"> - <section ids="section-1" names="section 1"> + <section ids="section-1" names="section\ 1"> <title> Section 1 - <section ids="subsection-1" names="subsection 1"> + <section ids="subsection-1" names="subsection\ 1"> <title> Subsection 1 <paragraph> Some text. <transition> - <section ids="section-2" names="section 2"> + <section ids="section-2" names="section\ 2"> <title> Section 2 <paragraph> @@ -72,7 +72,7 @@ Paragraph. <paragraph> A paragraph. <transition> - <section ids="section-1" names="section 1"> + <section ids="section-1" names="section\ 1"> <title> Section 1 <paragraph> @@ -146,7 +146,7 @@ Section 2 <document source="test data"> <paragraph> Sections with transitions at beginning and end. - <section ids="section-1" names="section 1"> + <section ids="section-1" names="section\ 1"> <title> Section 1 <system_message level="3" line="6" source="test data" type="ERROR"> @@ -156,7 +156,7 @@ Section 2 <paragraph> The next transition is legal: <transition> - <section ids="section-2" names="section 2"> + <section ids="section-2" names="section\ 2"> <title> Section 2 <system_message level="3" line="15" source="test data" type="ERROR"> @@ -239,7 +239,7 @@ Some text. """, """\ <document source="test data"> - <section ids="section-1" names="section 1"> + <section ids="section-1" names="section\ 1"> <title> Section 1 <system_message level="3" line="4" source="test data" type="ERROR"> @@ -254,7 +254,7 @@ Some text. <paragraph> At least one body element must separate transitions; adjacent transitions are not allowed. <transition> - <section ids="section-2" names="section 2"> + <section ids="section-2" names="section\ 2"> <title> Section 2 <paragraph> -- cgit v1.2.1 From 7e720ee65bc79a0430adb825f3deae4c93424959 Mon Sep 17 00:00:00 2001 From: goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> Date: Sat, 3 Dec 2005 02:13:12 +0000 Subject: corrected order of imports git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4132 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_transforms/test_transitions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/test_transforms/test_transitions.py') diff --git a/test/test_transforms/test_transitions.py b/test/test_transforms/test_transitions.py index e450ddff7..098c8bba3 100755 --- a/test/test_transforms/test_transitions.py +++ b/test/test_transforms/test_transitions.py @@ -10,8 +10,8 @@ Test module for misc.Transitions transform. """ +from __init__ import DocutilsTestSupport # must be imported before docutils from docutils.transforms.misc import Transitions -from __init__ import DocutilsTestSupport from docutils.parsers.rst import Parser def suite(): -- cgit v1.2.1