diff options
Diffstat (limited to 'docutils/test/test_transforms')
| -rw-r--r-- | docutils/test/test_transforms/__init__.py | 14 | ||||
| -rwxr-xr-x | docutils/test/test_transforms/test_class.py | 104 | ||||
| -rwxr-xr-x | docutils/test/test_transforms/test_contents.py | 377 | ||||
| -rwxr-xr-x | docutils/test/test_transforms/test_docinfo.py | 336 | ||||
| -rwxr-xr-x | docutils/test/test_transforms/test_doctitle.py | 175 | ||||
| -rw-r--r-- | docutils/test/test_transforms/test_filter.py | 41 | ||||
| -rwxr-xr-x | docutils/test/test_transforms/test_final_checks.py | 46 | ||||
| -rwxr-xr-x | docutils/test/test_transforms/test_footnotes.py | 520 | ||||
| -rwxr-xr-x | docutils/test/test_transforms/test_hyperlinks.py | 520 | ||||
| -rwxr-xr-x | docutils/test/test_transforms/test_messages.py | 66 | ||||
| -rw-r--r-- | docutils/test/test_transforms/test_peps.py | 68 | ||||
| -rw-r--r-- | docutils/test/test_transforms/test_sectnum.py | 226 | ||||
| -rwxr-xr-x | docutils/test/test_transforms/test_substitutions.py | 151 |
13 files changed, 0 insertions, 2644 deletions
diff --git a/docutils/test/test_transforms/__init__.py b/docutils/test/test_transforms/__init__.py deleted file mode 100644 index 2fe79c55c..000000000 --- a/docutils/test/test_transforms/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import os.path -import sys - -sys.path.insert(0, os.path.abspath(os.curdir)) -prev = '' -while sys.path[0] != prev: - try: - import DocutilsTestSupport - break - except ImportError: - prev = sys.path[0] - sys.path[0] = os.path.dirname(prev) -sys.path.pop(0) diff --git a/docutils/test/test_transforms/test_class.py b/docutils/test/test_transforms/test_class.py deleted file mode 100755 index db5a1cbdf..000000000 --- a/docutils/test/test_transforms/test_class.py +++ /dev/null @@ -1,104 +0,0 @@ -#! /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. - -""" -Tests for `docutils.transforms.misc.ClassAttribute`. -""" - -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['tables_of_contents'] = ((), [ -["""\ -.. class:: one - -paragraph -""", -"""\ -<document source="test data"> - <paragraph class="one"> - paragraph -"""], -["""\ -.. class:: two -.. - - Block quote -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - <block_quote class="two"> - <paragraph> - Block quote -"""], -["""\ - Block quote - - .. class:: three - -Paragraph -""", -"""\ -<document source="test data"> - <block_quote> - <paragraph> - Block quote - <paragraph class="three"> - Paragraph -"""], -["""\ -.. class:: four - -Section Title -============= - -Paragraph -""", -"""\ -<document source="test data"> - <section class="four" id="section-title" name="section title"> - <title> - Section Title - <paragraph> - Paragraph -"""], -["""\ -.. class:: - -.. class:: 99 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "class" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - .. class:: - <system_message level="3" line="3" source="test data" type="ERROR"> - <paragraph> - Invalid class attribute value for "class" directive: 99 - <literal_block xml:space="preserve"> - .. class:: 99 -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_contents.py b/docutils/test/test_transforms/test_contents.py deleted file mode 100755 index 5f54e7a74..000000000 --- a/docutils/test/test_transforms/test_contents.py +++ /dev/null @@ -1,377 +0,0 @@ -#! /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. - -""" -Tests for `docutils.transforms.parts.Contents` (via -`docutils.transforms.universal.LastReaderPending`). -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import Substitutions -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['tables_of_contents'] = ((Substitutions,), [ -["""\ -.. contents:: - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -"""\ -<document source="test data"> - <topic class="contents" id="contents" name="contents"> - <title> - Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - Title 1 - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - Title 2 - <bullet_list> - <list_item> - <paragraph> - <reference id="id3" refid="title-3"> - Title 3 - <list_item> - <paragraph> - <reference id="id4" refid="title-4"> - Title 4 - <section id="title-1" name="title 1"> - <title refid="id1"> - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id2"> - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title refid="id3"> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title refid="id4"> - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -.. contents:: Table of Contents - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. -""", -"""\ -<document source="test data"> - <topic class="contents" id="table-of-contents" name="table of contents"> - <title> - Table of Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - Title 1 - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - Title 2 - <section id="title-1" name="title 1"> - <title refid="id1"> - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id2"> - Title 2 - <paragraph> - Paragraph 2. -"""], -["""\ -.. contents:: There's an image in Title 2 - -Title 1 -======= -Paragraph 1. - -|Title 2| -========= -Paragraph 2. - -.. |Title 2| image:: title2.png -""", -"""\ -<document source="test data"> - <topic class="contents" id="there-s-an-image-in-title-2" name="there's an image in title 2"> - <title> - There's an image in Title 2 - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - Title 1 - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - Title 2 - <section id="title-1" name="title 1"> - <title refid="id1"> - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id2"> - <image alt="Title 2" uri="title2.png"> - <paragraph> - Paragraph 2. - <substitution_definition name="Title 2"> - <image alt="Title 2" uri="title2.png"> -"""], # emacs cruft: " -["""\ -.. contents:: - :depth: 2 - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -"""\ -<document source="test data"> - <topic class="contents" id="contents" name="contents"> - <title> - Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - Title 1 - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - Title 2 - <list_item> - <paragraph> - <reference id="id3" refid="title-4"> - Title 4 - <section id="title-1" name="title 1"> - <title refid="id1"> - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id2"> - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title refid="id3"> - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -Title 1 -======= - -.. contents:: - :local: - -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -"""\ -<document source="test data"> - <section id="title-1" name="title 1"> - <title> - Title 1 - <topic class="contents" id="contents" name="contents"> - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-2"> - Title 2 - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="title-3"> - Title 3 - <list_item> - <paragraph> - <reference id="id3" refid="title-4"> - Title 4 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id1"> - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title refid="id2"> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title refid="id3"> - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -.. contents:: - :local: - -Test duplicate name "Contents". - -Contents --------- -Paragraph. -""", -"""\ -<document source="test data"> - <topic class="contents" id="id1"> - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="contents"> - Contents - <paragraph> - Test duplicate name "Contents". - <section id="contents" name="contents"> - <title refid="id2"> - Contents - <paragraph> - Paragraph. -"""], -["""\ -.. contents:: - :backlinks: top - -Contents --------- -Paragraph. -""", -"""\ -<document source="test data"> - <topic class="contents" id="id1"> - <title> - Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="contents"> - Contents - <section id="contents" name="contents"> - <title refid="id1"> - Contents - <paragraph> - Paragraph. -"""], -["""\ -.. contents:: - :backlinks: none - -Contents --------- -Paragraph. -""", -"""\ -<document source="test data"> - <topic class="contents" id="id1"> - <title> - Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="contents"> - Contents - <section id="contents" name="contents"> - <title> - Contents - <paragraph> - Paragraph. -"""], -["""\ -.. contents:: - -Degenerate case, no table of contents generated. -""", -"""\ -<document source="test data"> - <paragraph> - Degenerate case, no table of contents generated. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_docinfo.py b/docutils/test/test_transforms/test_docinfo.py deleted file mode 100755 index 9fafa4ccb..000000000 --- a/docutils/test/test_transforms/test_docinfo.py +++ /dev/null @@ -1,336 +0,0 @@ -#! /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. - -""" -Tests for docutils.transforms.frontmatter.DocInfo. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.frontmatter import DocInfo -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['bibliographic_field_lists'] = ((DocInfo,), [ -["""\ -.. Bibliographic element extraction. - -:Abstract: - There can only be one abstract. - - It is automatically moved to the end of the other bibliographic elements. - -:Author: Me -:Version: 1 -:Date: 2001-08-11 -:Parameter i: integer -""", -"""\ -<document source="test data"> - <docinfo> - <author> - Me - <version> - 1 - <date> - 2001-08-11 - <field> - <field_name> - Parameter i - <field_body> - <paragraph> - integer - <topic class="abstract"> - <title> - Abstract - <paragraph> - There can only be one abstract. - <paragraph> - It is automatically moved to the end of the other bibliographic elements. - <comment xml:space="preserve"> - Bibliographic element extraction. -"""], -["""\ -.. Bibliographic element extraction. - -:Abstract: Abstract 1. -:Author: Me -:Address: 123 My Street - Example, EX -:Contact: me@my.org -:Version: 1 -:Abstract: Abstract 2 (should generate a warning). -:Date: 2001-08-11 -:Parameter i: integer -""", -"""\ -<document source="test data"> - <docinfo> - <author> - Me - <address xml:space="preserve"> - 123 My Street - Example, EX - <contact> - <reference refuri="mailto:me@my.org"> - me@my.org - <version> - 1 - <field> - <field_name> - Abstract - <field_body> - <paragraph> - Abstract 2 (should generate a warning). - <system_message level="2" line="9" source="test data" type="WARNING"> - <paragraph> - There can only be one "Abstract" field. - <date> - 2001-08-11 - <field> - <field_name> - Parameter i - <field_body> - <paragraph> - integer - <topic class="abstract"> - <title> - Abstract - <paragraph> - Abstract 1. - <comment xml:space="preserve"> - Bibliographic element extraction. -"""], -["""\ -:Author: - must be a paragraph -:Status: a *simple* paragraph -:Date: But only one - - paragraph. -:Version: - -.. and not empty either -""", -"""\ -<document source="test data"> - <docinfo> - <field> - <field_name> - Author - <field_body> - <bullet_list bullet="-"> - <list_item> - <paragraph> - must be a paragraph - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Cannot extract bibliographic field "Author" containing anything other than a single paragraph. - <status> - a \n\ - <emphasis> - simple - paragraph - <field> - <field_name> - Date - <field_body> - <paragraph> - But only one - <paragraph> - paragraph. - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Cannot extract compound bibliographic field "Date". - <field> - <field_name> - Version - <field_body> - <system_message level="2" line="6" source="test data" type="WARNING"> - <paragraph> - Cannot extract empty bibliographic field "Version". - <comment xml:space="preserve"> - and not empty either -"""], -["""\ -:Authors: Me, Myself, **I** -:Authors: PacMan; Ms. PacMan; PacMan, Jr. -:Authors: - Here - - There - - *Everywhere* -:Authors: - First - - Second - - Third -""", -"""\ -<document source="test data"> - <docinfo> - <authors> - <author> - Me - <author> - Myself - <author> - I - <authors> - <author> - PacMan - <author> - Ms. PacMan - <author> - PacMan, Jr. - <authors> - <author> - Here - <author> - There - <author> - <emphasis> - Everywhere - <authors> - <author> - First - <author> - Second - <author> - Third -"""], -["""\ -:Authors: Only One -:Authors: One, Only; -""", -"""\ -<document source="test data"> - <docinfo> - <author> - Only One - <author> - One, Only -"""], -["""\ -:Authors: - -:Authors: 1. One - 2. Two - -:Authors: - - - - - -:Authors: - - One - - Two - -:Authors: - - One - - Two -""", -"""\ -<document source="test data"> - <docinfo> - <field> - <field_name> - Authors - <field_body> - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Cannot extract empty bibliographic field "Authors". - <field> - <field_name> - Authors - <field_body> - <enumerated_list enumtype="arabic" prefix="" suffix="."> - <list_item> - <paragraph> - One - <list_item> - <paragraph> - Two - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item. - <field> - <field_name> - Authors - <field_body> - <bullet_list bullet="-"> - <list_item> - <list_item> - <system_message level="2" line="6" source="test data" type="WARNING"> - <paragraph> - Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item. - <field> - <field_name> - Authors - <field_body> - <bullet_list bullet="-"> - <list_item> - <paragraph> - One - <paragraph> - Two - <system_message level="2" line="10" source="test data" type="WARNING"> - <paragraph> - Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item. - <field> - <field_name> - Authors - <field_body> - <bullet_list bullet="-"> - <list_item> - <paragraph> - One - <paragraph> - Two - <system_message level="2" line="15" source="test data" type="WARNING"> - <paragraph> - Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item. -"""], -["""\ -.. RCS keyword extraction. - -:Status: $RCSfile$ -:Date: $Date$ - -RCS keyword 'RCSfile' doesn't change unless the file name changes, -so it's safe. The 'Date' keyword changes every time the file is -checked in to CVS, so the test's expected output text has to be -derived (hacked) in parallel in order to stay in sync. -""", -"""\ -<document source="test data"> - <docinfo> - <status> - test_docinfo.py - <date> - %s - <comment xml:space="preserve"> - RCS keyword extraction. - <paragraph> - RCS keyword 'RCSfile' doesn't change unless the file name changes, - so it's safe. The 'Date' keyword changes every time the file is - checked in to CVS, so the test's expected output text has to be - derived (hacked) in parallel in order to stay in sync. -""" % ('$Date$'[7:17].replace('/', '-'),)], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_doctitle.py b/docutils/test/test_transforms/test_doctitle.py deleted file mode 100755 index 3e08eb232..000000000 --- a/docutils/test/test_transforms/test_doctitle.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /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. - -""" -Tests for docutils.transforms.frontmatter.DocTitle. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.frontmatter import DocTitle -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['section_headers'] = ((DocTitle,), [ -["""\ -.. test title promotion - -Title -===== - -Paragraph. -""", -"""\ -<document id="title" name="title" source="test data"> - <title> - Title - <comment xml:space="preserve"> - test title promotion - <paragraph> - Paragraph. -"""], -["""\ -Title -===== -Paragraph (no blank line). -""", -"""\ -<document id="title" name="title" source="test data"> - <title> - Title - <paragraph> - Paragraph (no blank line). -"""], -["""\ -Paragraph. - -Title -===== - -Paragraph. -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph. - <section id="title" name="title"> - <title> - Title - <paragraph> - Paragraph. -"""], -["""\ -Title -===== - -Subtitle --------- - -Test title & subtitle. -""", -"""\ -<document id="title" name="title" source="test data"> - <title> - Title - <subtitle id="subtitle" name="subtitle"> - Subtitle - <paragraph> - Test title & subtitle. -"""], -["""\ -Title -==== - -Test short underline. -""", -"""\ -<document id="title" name="title" source="test data"> - <title> - Title - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Title underline too short. - <literal_block xml:space="preserve"> - Title - ==== - <paragraph> - Test short underline. -"""], -["""\ -======= - Long Title -======= - -Test long title and space normalization. -The system_message should move after the document title -(it was before the beginning of the section). -""", -"""\ -<document id="long-title" name="long title" source="test data"> - <title> - Long Title - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Title overline too short. - <literal_block xml:space="preserve"> - ======= - Long Title - ======= - <paragraph> - Test long title and space normalization. - The system_message should move after the document title - (it was before the beginning of the section). -"""], -["""\ -.. Test multiple second-level titles. - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -------- -Paragraph 3. -""", -"""\ -<document id="title-1" name="title 1" source="test data"> - <title> - Title 1 - <comment xml:space="preserve"> - Test multiple second-level titles. - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title> - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title> - Title 3 - <paragraph> - Paragraph 3. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_filter.py b/docutils/test/test_transforms/test_filter.py deleted file mode 100644 index 009600d81..000000000 --- a/docutils/test/test_transforms/test_filter.py +++ /dev/null @@ -1,41 +0,0 @@ -#! /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. - -""" -Tests for docutils.transforms.components.Filter. -""" - -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['meta'] = ((), [ -["""\ -.. meta:: - :description: The reStructuredText plaintext markup language - :keywords: plaintext,markup language -""", -"""\ -<document source="test data"> - <meta content="The reStructuredText plaintext markup language" name="description"> - <meta content="plaintext,markup language" name="keywords"> -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_final_checks.py b/docutils/test/test_transforms/test_final_checks.py deleted file mode 100755 index 36c55efda..000000000 --- a/docutils/test/test_transforms/test_final_checks.py +++ /dev/null @@ -1,46 +0,0 @@ -#! /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. - -""" -Tests for docutils.transforms.universal.FinalChecks. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.universal import FinalChecks -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['final_checks'] = ((FinalChecks,), [ -["""\ -Unknown reference_. -""", -"""\ -<document source="test data"> - <paragraph> - Unknown \n\ - <problematic id="id2" refid="id1"> - reference_ - . - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Unknown target name: "reference". -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_footnotes.py b/docutils/test/test_transforms/test_footnotes.py deleted file mode 100755 index 4da43e055..000000000 --- a/docutils/test/test_transforms/test_footnotes.py +++ /dev/null @@ -1,520 +0,0 @@ -#! /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. - -""" -Tests for docutils.transforms.references.Footnotes. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import Footnotes -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['footnotes'] = ((Footnotes,), [ -["""\ -[#autolabel]_ - -.. [#autolabel] text -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference auto="1" id="id1" refid="autolabel"> - 1 - <footnote auto="1" backrefs="id1" id="autolabel" name="autolabel"> - <label> - 1 - <paragraph> - text -"""], -["""\ -autonumber: [#]_ - -.. [#] text -""", -"""\ -<document source="test data"> - <paragraph> - autonumber: \n\ - <footnote_reference auto="1" id="id1" refid="id2"> - 1 - <footnote auto="1" backrefs="id1" id="id2" name="1"> - <label> - 1 - <paragraph> - text -"""], -["""\ -[#]_ is the first auto-numbered footnote reference. -[#]_ is the second auto-numbered footnote reference. - -.. [#] Auto-numbered footnote 1. -.. [#] Auto-numbered footnote 2. -.. [#] Auto-numbered footnote 3. - -[#]_ is the third auto-numbered footnote reference. -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference auto="1" id="id1" refid="id3"> - 1 - is the first auto-numbered footnote reference. - <footnote_reference auto="1" id="id2" refid="id4"> - 2 - is the second auto-numbered footnote reference. - <footnote auto="1" backrefs="id1" id="id3" name="1"> - <label> - 1 - <paragraph> - Auto-numbered footnote 1. - <footnote auto="1" backrefs="id2" id="id4" name="2"> - <label> - 2 - <paragraph> - Auto-numbered footnote 2. - <footnote auto="1" backrefs="id6" id="id5" name="3"> - <label> - 3 - <paragraph> - Auto-numbered footnote 3. - <paragraph> - <footnote_reference auto="1" id="id6" refid="id5"> - 3 - is the third auto-numbered footnote reference. -"""], -["""\ -[#third]_ is a reference to the third auto-numbered footnote. - -.. [#first] First auto-numbered footnote. -.. [#second] Second auto-numbered footnote. -.. [#third] Third auto-numbered footnote. - -[#second]_ is a reference to the second auto-numbered footnote. -[#first]_ is a reference to the first auto-numbered footnote. -[#third]_ is another reference to the third auto-numbered footnote. - -Here are some internal cross-references to the implicit targets -generated by the footnotes: first_, second_, third_. -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference auto="1" id="id1" refid="third"> - 3 - is a reference to the third auto-numbered footnote. - <footnote auto="1" backrefs="id3" id="first" name="first"> - <label> - 1 - <paragraph> - First auto-numbered footnote. - <footnote auto="1" backrefs="id2" id="second" name="second"> - <label> - 2 - <paragraph> - Second auto-numbered footnote. - <footnote auto="1" backrefs="id1 id4" id="third" name="third"> - <label> - 3 - <paragraph> - Third auto-numbered footnote. - <paragraph> - <footnote_reference auto="1" id="id2" refid="second"> - 2 - is a reference to the second auto-numbered footnote. - <footnote_reference auto="1" id="id3" refid="first"> - 1 - is a reference to the first auto-numbered footnote. - <footnote_reference auto="1" id="id4" refid="third"> - 3 - is another reference to the third auto-numbered footnote. - <paragraph> - Here are some internal cross-references to the implicit targets - generated by the footnotes: \n\ - <reference refname="first"> - first - , \n\ - <reference refname="second"> - second - , \n\ - <reference refname="third"> - third - . -"""], -["""\ -Mixed anonymous and labelled auto-numbered footnotes: - -[#four]_ should be 4, [#]_ should be 1, -[#]_ should be 3, [#]_ is one too many, -[#two]_ should be 2, and [#six]_ doesn't exist. - -.. [#] Auto-numbered footnote 1. -.. [#two] Auto-numbered footnote 2. -.. [#] Auto-numbered footnote 3. -.. [#four] Auto-numbered footnote 4. -.. [#five] Auto-numbered footnote 5. -.. [#five] Auto-numbered footnote 5 again (duplicate). -""", -"""\ -<document source="test data"> - <paragraph> - Mixed anonymous and labelled auto-numbered footnotes: - <paragraph> - <footnote_reference auto="1" id="id1" refid="four"> - 4 - should be 4, \n\ - <footnote_reference auto="1" id="id2" refid="id7"> - 1 - should be 1, - <footnote_reference auto="1" id="id3" refid="id8"> - 3 - should be 3, \n\ - <problematic id="id11" refid="id10"> - [#]_ - is one too many, - <footnote_reference auto="1" id="id5" refid="two"> - 2 - should be 2, and \n\ - <footnote_reference auto="1" id="id6" refname="six"> - doesn't exist. - <footnote auto="1" backrefs="id2" id="id7" name="1"> - <label> - 1 - <paragraph> - Auto-numbered footnote 1. - <footnote auto="1" backrefs="id5" id="two" name="two"> - <label> - 2 - <paragraph> - Auto-numbered footnote 2. - <footnote auto="1" backrefs="id3" id="id8" name="3"> - <label> - 3 - <paragraph> - Auto-numbered footnote 3. - <footnote auto="1" backrefs="id1" id="four" name="four"> - <label> - 4 - <paragraph> - Auto-numbered footnote 4. - <footnote auto="1" dupname="five" id="five"> - <label> - 5 - <paragraph> - Auto-numbered footnote 5. - <footnote auto="1" dupname="five" id="id9"> - <label> - 6 - <system_message backrefs="id9" level="2" line="12" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "five". - <paragraph> - Auto-numbered footnote 5 again (duplicate). - <system_message backrefs="id11" id="id10" level="3" line="3" source="test data" type="ERROR"> - <paragraph> - Too many autonumbered footnote references: only 2 corresponding footnotes available. -"""], -["""\ -Mixed auto-numbered and manual footnotes: - -.. [1] manually numbered -.. [#] auto-numbered -.. [#label] autonumber-labeled -""", -"""\ -<document source="test data"> - <paragraph> - Mixed auto-numbered and manual footnotes: - <footnote id="id1" name="1"> - <label> - 1 - <paragraph> - manually numbered - <footnote auto="1" id="id2" name="2"> - <label> - 2 - <paragraph> - auto-numbered - <footnote auto="1" id="label" name="label"> - <label> - 3 - <paragraph> - autonumber-labeled -"""], -["""\ -A labeled autonumbered footnote referece: [#footnote]_. - -An unlabeled autonumbered footnote referece: [#]_. - -.. [#] Unlabeled autonumbered footnote. -.. [#footnote] Labeled autonumbered footnote. - Note that the footnotes are not in the same - order as the references. -""", -"""\ -<document source="test data"> - <paragraph> - A labeled autonumbered footnote referece: \n\ - <footnote_reference auto="1" id="id1" refid="footnote"> - 2 - . - <paragraph> - An unlabeled autonumbered footnote referece: \n\ - <footnote_reference auto="1" id="id2" refid="id3"> - 1 - . - <footnote auto="1" backrefs="id2" id="id3" name="1"> - <label> - 1 - <paragraph> - Unlabeled autonumbered footnote. - <footnote auto="1" backrefs="id1" id="footnote" name="footnote"> - <label> - 2 - <paragraph> - Labeled autonumbered footnote. - Note that the footnotes are not in the same - order as the references. -"""], -["""\ -Mixed manually-numbered, anonymous auto-numbered, -and labelled auto-numbered footnotes: - -[#four]_ should be 4, [#]_ should be 2, -[1]_ is 1, [3]_ is 3, -[#]_ should be 6, [#]_ is one too many, -[#five]_ should be 5, and [#eight]_ doesn't exist. - -.. [1] Manually-numbered footnote 1. -.. [#] Auto-numbered footnote 2. -.. [#four] Auto-numbered footnote 4. -.. [3] Manually-numbered footnote 3 -.. [#five] Auto-numbered footnote 5. -.. [#] Auto-numbered footnote 6. -.. [#five] Auto-numbered footnote 5 again (duplicate). -""", -"""\ -<document source="test data"> - <paragraph> - Mixed manually-numbered, anonymous auto-numbered, - and labelled auto-numbered footnotes: - <paragraph> - <footnote_reference auto="1" id="id1" refid="four"> - 4 - should be 4, \n\ - <footnote_reference auto="1" id="id2" refid="id10"> - 2 - should be 2, - <footnote_reference id="id3" refid="id9"> - 1 - is 1, \n\ - <footnote_reference id="id4" refid="id11"> - 3 - is 3, - <footnote_reference auto="1" id="id5" refid="id12"> - 6 - should be 6, \n\ - <problematic id="id15" refid="id14"> - [#]_ - is one too many, - <footnote_reference auto="1" id="id7" refname="five"> - should be 5, and \n\ - <footnote_reference auto="1" id="id8" refname="eight"> - doesn't exist. - <footnote backrefs="id3" id="id9" name="1"> - <label> - 1 - <paragraph> - Manually-numbered footnote 1. - <footnote auto="1" backrefs="id2" id="id10" name="2"> - <label> - 2 - <paragraph> - Auto-numbered footnote 2. - <footnote auto="1" backrefs="id1" id="four" name="four"> - <label> - 4 - <paragraph> - Auto-numbered footnote 4. - <footnote backrefs="id4" id="id11" name="3"> - <label> - 3 - <paragraph> - Manually-numbered footnote 3 - <footnote auto="1" dupname="five" id="five"> - <label> - 5 - <paragraph> - Auto-numbered footnote 5. - <footnote auto="1" backrefs="id5" id="id12" name="6"> - <label> - 6 - <paragraph> - Auto-numbered footnote 6. - <footnote auto="1" dupname="five" id="id13"> - <label> - 7 - <system_message backrefs="id13" level="2" line="15" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "five". - <paragraph> - Auto-numbered footnote 5 again (duplicate). - <system_message backrefs="id15" id="id14" level="3" line="4" source="test data" type="ERROR"> - <paragraph> - Too many autonumbered footnote references: only 2 corresponding footnotes available. -"""], -["""\ -Referencing a footnote by symbol [*]_. - -.. [*] This is an auto-symbol footnote. -""", -"""\ -<document source="test data"> - <paragraph> - Referencing a footnote by symbol \n\ - <footnote_reference auto="*" id="id1" refid="id2"> - * - . - <footnote auto="*" backrefs="id1" id="id2"> - <label> - * - <paragraph> - This is an auto-symbol footnote. -"""], -["""\ -A sequence of symbol footnote references: -[*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_. - -.. [*] Auto-symbol footnote 1. -.. [*] Auto-symbol footnote 2. -.. [*] Auto-symbol footnote 3. -.. [*] Auto-symbol footnote 4. -.. [*] Auto-symbol footnote 5. -.. [*] Auto-symbol footnote 6. -.. [*] Auto-symbol footnote 7. -.. [*] Auto-symbol footnote 8. -.. [*] Auto-symbol footnote 9. -.. [*] Auto-symbol footnote 10. -.. [*] Auto-symbol footnote 11. -.. [*] Auto-symbol footnote 12. -""", -u"""\ -<document source="test data"> - <paragraph> - A sequence of symbol footnote references: - <footnote_reference auto="*" id="id1" refid="id13"> - * - \n\ - <footnote_reference auto="*" id="id2" refid="id14"> - \u2020 - \n\ - <footnote_reference auto="*" id="id3" refid="id15"> - \u2021 - \n\ - <footnote_reference auto="*" id="id4" refid="id16"> - \u00A7 - \n\ - <footnote_reference auto="*" id="id5" refid="id17"> - \u00B6 - \n\ - <footnote_reference auto="*" id="id6" refid="id18"> - # - \n\ - <footnote_reference auto="*" id="id7" refid="id19"> - \u2660 - \n\ - <footnote_reference auto="*" id="id8" refid="id20"> - \u2665 - \n\ - <footnote_reference auto="*" id="id9" refid="id21"> - \u2666 - \n\ - <footnote_reference auto="*" id="id10" refid="id22"> - \u2663 - \n\ - <footnote_reference auto="*" id="id11" refid="id23"> - ** - \n\ - <footnote_reference auto="*" id="id12" refid="id24"> - \u2020\u2020 - . - <footnote auto="*" backrefs="id1" id="id13"> - <label> - * - <paragraph> - Auto-symbol footnote 1. - <footnote auto="*" backrefs="id2" id="id14"> - <label> - \u2020 - <paragraph> - Auto-symbol footnote 2. - <footnote auto="*" backrefs="id3" id="id15"> - <label> - \u2021 - <paragraph> - Auto-symbol footnote 3. - <footnote auto="*" backrefs="id4" id="id16"> - <label> - \u00A7 - <paragraph> - Auto-symbol footnote 4. - <footnote auto="*" backrefs="id5" id="id17"> - <label> - \u00B6 - <paragraph> - Auto-symbol footnote 5. - <footnote auto="*" backrefs="id6" id="id18"> - <label> - # - <paragraph> - Auto-symbol footnote 6. - <footnote auto="*" backrefs="id7" id="id19"> - <label> - \u2660 - <paragraph> - Auto-symbol footnote 7. - <footnote auto="*" backrefs="id8" id="id20"> - <label> - \u2665 - <paragraph> - Auto-symbol footnote 8. - <footnote auto="*" backrefs="id9" id="id21"> - <label> - \u2666 - <paragraph> - Auto-symbol footnote 9. - <footnote auto="*" backrefs="id10" id="id22"> - <label> - \u2663 - <paragraph> - Auto-symbol footnote 10. - <footnote auto="*" backrefs="id11" id="id23"> - <label> - ** - <paragraph> - Auto-symbol footnote 11. - <footnote auto="*" backrefs="id12" id="id24"> - <label> - \u2020\u2020 - <paragraph> - Auto-symbol footnote 12. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_hyperlinks.py b/docutils/test/test_transforms/test_hyperlinks.py deleted file mode 100755 index 43e18d3f2..000000000 --- a/docutils/test/test_transforms/test_hyperlinks.py +++ /dev/null @@ -1,520 +0,0 @@ -#! /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. - -""" -Tests for docutils.transforms.references.Hyperlinks. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import ChainedTargets, \ - AnonymousHyperlinks, IndirectHyperlinks, ExternalTargets, InternalTargets -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -# Exhaustive listing of hyperlink variations: every combination of -# target/reference, direct/indirect, internal/external, and named/anonymous, -# plus embedded URIs. -totest['exhaustive_hyperlinks'] = ((ChainedTargets, AnonymousHyperlinks, - IndirectHyperlinks, ExternalTargets, - InternalTargets,), [ -["""\ -direct_ external - -.. _direct: http://direct -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://direct"> - direct - external - <target id="direct" name="direct" refuri="http://direct"> -"""], -["""\ -indirect_ external - -.. _indirect: xtarget_ -.. _xtarget: http://indirect -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://indirect"> - indirect - external - <target id="indirect" name="indirect" refuri="http://indirect"> - <target id="xtarget" name="xtarget" refuri="http://indirect"> -"""], -["""\ -.. _direct: - -direct_ internal -""", -"""\ -<document source="test data"> - <target id="direct" name="direct"> - <paragraph> - <reference refid="direct"> - direct - internal -"""], -["""\ -.. _ztarget: - -indirect_ internal - -.. _indirect2: ztarget_ -.. _indirect: indirect2_ -""", -"""\ -<document source="test data"> - <target id="ztarget" name="ztarget"> - <paragraph> - <reference refid="ztarget"> - indirect - internal - <target id="indirect2" name="indirect2" refid="ztarget"> - <target id="indirect" name="indirect" refid="ztarget"> -"""], -["""\ -Implicit --------- - -indirect_ internal - -.. _indirect: implicit_ -""", -"""\ -<document source="test data"> - <section id="implicit" name="implicit"> - <title> - Implicit - <paragraph> - <reference refid="implicit"> - indirect - internal - <target id="indirect" name="indirect" refid="implicit"> -"""], -["""\ -Implicit --------- - -`multiply-indirect`_ internal - -.. _multiply-indirect: indirect_ -.. _indirect: implicit_ -""", -"""\ -<document source="test data"> - <section id="implicit" name="implicit"> - <title> - Implicit - <paragraph> - <reference refid="implicit"> - multiply-indirect - internal - <target id="multiply-indirect" name="multiply-indirect" refid="implicit"> - <target id="indirect" name="indirect" refid="implicit"> -"""], -["""\ -circular_ indirect reference - -.. _circular: indirect_ -.. _indirect: circular_ -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - circular_ - indirect reference - <target id="circular" name="circular" refid="circular"> - <problematic id="id3" refid="id1"> - .. _indirect: circular_ - <system_message backrefs="id2 id3" id="id1" level="3" line="3" source="test data" type="ERROR"> - <paragraph> - Indirect hyperlink target "circular" (id="circular") refers to target "indirect", forming a circular reference. -"""], -["""\ -Implicit --------- - -Duplicate implicit targets. - -Implicit --------- - -indirect_ internal - -.. _indirect: implicit_ -""", -"""\ -<document source="test data"> - <section dupname="implicit" id="implicit"> - <title> - Implicit - <paragraph> - Duplicate implicit targets. - <section dupname="implicit" id="id1"> - <title> - Implicit - <system_message backrefs="id1" level="1" line="7" source="test data" type="INFO"> - <paragraph> - Duplicate implicit target name: "implicit". - <paragraph> - <problematic id="id3" refid="id2"> - indirect_ - internal - <target id="indirect" name="indirect" refname="implicit"> - <system_message backrefs="id3" id="id2" level="3" line="11" source="test data" type="ERROR"> - <paragraph> - Indirect hyperlink target "indirect" (id="indirect") refers to target "implicit", which does not exist. -"""], -["""\ -`direct external`__ - -__ http://direct -""", -"""\ -<document source="test data"> - <paragraph> - <reference anonymous="1" refuri="http://direct"> - direct external - <target anonymous="1" id="id1" refuri="http://direct"> -"""], -["""\ -`indirect external`__ - -__ xtarget_ -.. _xtarget: http://indirect -""", -"""\ -<document source="test data"> - <paragraph> - <reference anonymous="1" refuri="http://indirect"> - indirect external - <target anonymous="1" id="id1" refuri="http://indirect"> - <target id="xtarget" name="xtarget" refuri="http://indirect"> -"""], -["""\ -__ - -`direct internal`__ -""", -"""\ -<document source="test data"> - <target anonymous="1" id="id1"> - <paragraph> - <reference anonymous="1" refid="id1"> - direct internal -"""], -["""\ -.. _ztarget: - -`indirect internal`__ - -__ ztarget_ -""", -"""\ -<document source="test data"> - <target id="ztarget" name="ztarget"> - <paragraph> - <reference anonymous="1" refid="ztarget"> - indirect internal - <target anonymous="1" id="id1" refid="ztarget"> -"""], -["""\ -.. _ztarget: - -First - -.. _ztarget: - -Second - -`indirect internal`__ - -__ ztarget_ -""", -"""\ -<document source="test data"> - <target dupname="ztarget" id="ztarget"> - <paragraph> - First - <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "ztarget". - <target dupname="ztarget" id="id1"> - <paragraph> - Second - <paragraph> - <problematic id="id4" refid="id3"> - `indirect internal`__ - <target anonymous="1" id="id2" refname="ztarget"> - <system_message backrefs="id4" id="id3" level="3" line="11" source="test data" type="ERROR"> - <paragraph> - Indirect hyperlink target (id="id2") refers to target "ztarget", which does not exist. -"""], -["""\ -An `embedded uri <http://direct>`_. - -Another reference to the same `embedded URI`_. -""", -"""\ -<document source="test data"> - <paragraph> - An \n\ - <reference refuri="http://direct"> - embedded uri - <target id="embedded-uri" name="embedded uri" refuri="http://direct"> - . - <paragraph> - Another reference to the same \n\ - <reference refuri="http://direct"> - embedded URI - . -"""], -["""\ -An `anonymous embedded uri <http://direct>`__. -""", -"""\ -<document source="test data"> - <paragraph> - An \n\ - <reference refuri="http://direct"> - anonymous embedded uri - . -"""], -]) - -totest['hyperlinks'] = ((ChainedTargets, AnonymousHyperlinks, - IndirectHyperlinks, ExternalTargets, - InternalTargets,), [ -["""\ -.. _internal hyperlink: - -This paragraph referenced. - -By this `internal hyperlink`_ referemce. -""", -"""\ -<document source="test data"> - <target id="internal-hyperlink" name="internal hyperlink"> - <paragraph> - This paragraph referenced. - <paragraph> - By this \n\ - <reference refid="internal-hyperlink"> - internal hyperlink - referemce. -"""], -["""\ -.. _chained: -.. _internal hyperlink: - -This paragraph referenced. - -By this `internal hyperlink`_ referemce -as well as by this chained_ reference. - -The results of the transform are not visible at the XML level. -""", -"""\ -<document source="test data"> - <target id="chained" name="chained"> - <target id="internal-hyperlink" name="internal hyperlink"> - <paragraph> - This paragraph referenced. - <paragraph> - By this \n\ - <reference refid="internal-hyperlink"> - internal hyperlink - referemce - as well as by this \n\ - <reference refid="chained"> - chained - reference. - <paragraph> - The results of the transform are not visible at the XML level. -"""], -["""\ -.. _external hyperlink: http://uri - -`External hyperlink`_ reference. -""", -"""\ -<document source="test data"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <paragraph> - <reference refuri="http://uri"> - External hyperlink - reference. -"""], -["""\ -.. _external hyperlink: http://uri -.. _indirect target: `external hyperlink`_ -""", -"""\ -<document source="test data"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <target id="indirect-target" name="indirect target" refuri="http://uri"> - <system_message level="1" line="2" source="test data" type="INFO"> - <paragraph> - Indirect hyperlink target "indirect target" is not referenced. -"""], -["""\ -.. _chained: -.. _external hyperlink: http://uri - -`External hyperlink`_ reference -and a chained_ reference too. -""", -"""\ -<document source="test data"> - <target id="chained" name="chained" refuri="http://uri"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <paragraph> - <reference refuri="http://uri"> - External hyperlink - reference - and a \n\ - <reference refuri="http://uri"> - chained - reference too. -"""], -["""\ -.. _external hyperlink: http://uri -.. _indirect hyperlink: `external hyperlink`_ - -`Indirect hyperlink`_ reference. -""", -"""\ -<document source="test data"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <target id="indirect-hyperlink" name="indirect hyperlink" refuri="http://uri"> - <paragraph> - <reference refuri="http://uri"> - Indirect hyperlink - reference. -"""], -["""\ -.. _external hyperlink: http://uri -.. _chained: -.. _indirect hyperlink: `external hyperlink`_ - -Chained_ `indirect hyperlink`_ reference. -""", -"""\ -<document source="test data"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <target id="chained" name="chained" refuri="http://uri"> - <target id="indirect-hyperlink" name="indirect hyperlink" refuri="http://uri"> - <paragraph> - <reference refuri="http://uri"> - Chained - \n\ - <reference refuri="http://uri"> - indirect hyperlink - reference. -"""], -["""\ -.. __: http://full -__ -__ http://simplified -.. _external: http://indirect.external -__ external_ -__ - -`Full syntax anonymous external hyperlink reference`__, -`chained anonymous external reference`__, -`simplified syntax anonymous external hyperlink reference`__, -`indirect anonymous hyperlink reference`__, -`internal anonymous hyperlink reference`__. -""", -"""\ -<document source="test data"> - <target anonymous="1" id="id1" refuri="http://full"> - <target anonymous="1" id="id2" refuri="http://simplified"> - <target anonymous="1" id="id3" refuri="http://simplified"> - <target id="external" name="external" refuri="http://indirect.external"> - <target anonymous="1" id="id4" refuri="http://indirect.external"> - <target anonymous="1" id="id5"> - <paragraph> - <reference anonymous="1" refuri="http://full"> - Full syntax anonymous external hyperlink reference - , - <reference anonymous="1" refuri="http://simplified"> - chained anonymous external reference - , - <reference anonymous="1" refuri="http://simplified"> - simplified syntax anonymous external hyperlink reference - , - <reference anonymous="1" refuri="http://indirect.external"> - indirect anonymous hyperlink reference - , - <reference anonymous="1" refid="id5"> - internal anonymous hyperlink reference - . -"""], -["""\ -Duplicate external target_'s (different URIs): - -.. _target: first - -.. _target: second -""", -"""\ -<document source="test data"> - <paragraph> - Duplicate external \n\ - <reference refname="target"> - target - 's (different URIs): - <target dupname="target" id="target" refuri="first"> - <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "target". - <target dupname="target" id="id1" refuri="second"> -"""], -["""\ -Several__ anonymous__ hyperlinks__, but not enough targets. - -__ http://example.org -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id3" refid="id2"> - Several__ - \n\ - <problematic id="id4" refid="id2"> - anonymous__ - \n\ - <problematic id="id5" refid="id2"> - hyperlinks__ - , but not enough targets. - <target anonymous="1" id="id1" refuri="http://example.org"> - <system_message backrefs="id3 id4 id5" id="id2" level="3" source="test data" type="ERROR"> - <paragraph> - Anonymous hyperlink mismatch: 3 references but 1 targets. - See "backrefs" attribute for IDs. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_messages.py b/docutils/test/test_transforms/test_messages.py deleted file mode 100755 index 75325bc96..000000000 --- a/docutils/test/test_transforms/test_messages.py +++ /dev/null @@ -1,66 +0,0 @@ -#! /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. - -""" -Tests for docutils.transforms.universal.Messages. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.universal import Messages -from docutils.transforms.references import Substitutions -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['system_message_sections'] = ((Substitutions, Messages), [ -["""\ -This |unknown substitution| will generate a system message, thanks to -the ``Substitutions`` transform. The ``Messages`` transform will -generate a "System Messages" section. - -(A second copy of the system message is tacked on to the end of the -document by the test framework.) -""", -"""\ -<document source="test data"> - <paragraph> - This \n\ - <problematic id="id2" refid="id1"> - |unknown substitution| - will generate a system message, thanks to - the \n\ - <literal> - Substitutions - transform. The \n\ - <literal> - Messages - transform will - generate a "System Messages" section. - <paragraph> - (A second copy of the system message is tacked on to the end of the - document by the test framework.) - <section class="system-messages"> - <title> - Docutils System Messages - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Undefined substitution referenced: "unknown substitution". -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_peps.py b/docutils/test/test_transforms/test_peps.py deleted file mode 100644 index 28fa68af2..000000000 --- a/docutils/test/test_transforms/test_peps.py +++ /dev/null @@ -1,68 +0,0 @@ -#! /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. - -""" -Tests for docutils.transforms.peps. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.peps import TargetNotes -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['target_notes'] = ((TargetNotes,), [ -["""\ -No references or targets exist, therefore -no "References" section should be generated. -""", -"""\ -<document source="test data"> - <paragraph> - No references or targets exist, therefore - no "References" section should be generated. -"""], -["""\ -A target exists, here's the reference_. -A "References" section should be generated. - -.. _reference: http://www.example.org -""", -"""\ -<document source="test data"> - <paragraph> - A target exists, here's the \n\ - <reference refname="reference"> - reference - \n\ - <footnote_reference auto="1" id="id3" refname="target_note: id2"> - . - A "References" section should be generated. - <target id="reference" name="reference" refuri="http://www.example.org"> - <section id="id1"> - <title> - References - <footnote auto="1" id="id2" name="target_note: id2"> - <paragraph> - <reference refuri="http://www.example.org"> - http://www.example.org -"""], -]) - - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_sectnum.py b/docutils/test/test_transforms/test_sectnum.py deleted file mode 100644 index 543deac16..000000000 --- a/docutils/test/test_transforms/test_sectnum.py +++ /dev/null @@ -1,226 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger, Dmitry Jemerov -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for `docutils.transforms.parts.SectNum` (via -`docutils.transforms.universal.LastReaderPending`). -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import Substitutions -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['section_numbers'] = ((Substitutions,), [ -["""\ -.. sectnum:: - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -u"""\ -<document source="test data"> - <section id="title-1" name="title 1"> - <title auto="1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title auto="1"> - <generated class="sectnum"> - 1.1\u00a0\u00a0\u00a0 - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title auto="1"> - <generated class="sectnum"> - 1.1.1\u00a0\u00a0\u00a0 - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title auto="1"> - <generated class="sectnum"> - 1.2\u00a0\u00a0\u00a0 - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -.. sectnum:: - -**Bold Title** -============== -Paragraph 1. -""", -u"""\ -<document source="test data"> - <section id="bold-title" name="bold title"> - <title auto="1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - <strong> - Bold Title - <paragraph> - Paragraph 1. -"""], -["""\ -.. sectnum:: :depth: 2 - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -u"""\ -<document source="test data"> - <section id="title-1" name="title 1"> - <title auto="1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title auto="1"> - <generated class="sectnum"> - 1.1\u00a0\u00a0\u00a0 - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title auto="1"> - <generated class="sectnum"> - 1.2\u00a0\u00a0\u00a0 - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -.. contents:: -.. sectnum:: :depth: 2 - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -u"""\ -<document source="test data"> - <topic class="contents" id="contents" name="contents"> - <title> - Contents - <bullet_list class="auto-toc"> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - Title 1 - <bullet_list class="auto-toc"> - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - <generated class="sectnum"> - 1.1\u00a0\u00a0\u00a0 - Title 2 - <bullet_list> - <list_item> - <paragraph> - <reference id="id3" refid="title-3"> - Title 3 - <list_item> - <paragraph> - <reference id="id4" refid="title-4"> - <generated class="sectnum"> - 1.2\u00a0\u00a0\u00a0 - Title 4 - <section id="title-1" name="title 1"> - <title auto="1" refid="id1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title auto="1" refid="id2"> - <generated class="sectnum"> - 1.1\u00a0\u00a0\u00a0 - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title refid="id3"> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title auto="1" refid="id4"> - <generated class="sectnum"> - 1.2\u00a0\u00a0\u00a0 - Title 4 - <paragraph> - Paragraph 4. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_substitutions.py b/docutils/test/test_transforms/test_substitutions.py deleted file mode 100755 index 503dfba40..000000000 --- a/docutils/test/test_transforms/test_substitutions.py +++ /dev/null @@ -1,151 +0,0 @@ -#! /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. - -""" -Tests for docutils.transforms.references.Substitutions. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import Substitutions -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['substitutions'] = ((Substitutions,), [ -["""\ -The |biohazard| symbol is deservedly scary-looking. - -.. |biohazard| image:: biohazard.png -""", -"""\ -<document source="test data"> - <paragraph> - The \n\ - <image alt="biohazard" uri="biohazard.png"> - symbol is deservedly scary-looking. - <substitution_definition name="biohazard"> - <image alt="biohazard" uri="biohazard.png"> -"""], -["""\ -Here's an |unknown| substitution. -""", -"""\ -<document source="test data"> - <paragraph> - Here's an \n\ - <problematic id="id2" refid="id1"> - |unknown| - substitution. - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Undefined substitution referenced: "unknown". -"""], -[u"""\ -Substitutions support case differences: - -.. |eacute| replace:: \u00E9 -.. |Eacute| replace:: \u00C9 - -|Eacute|\\t\\ |eacute|, and even |EACUTE|. -""", -u"""\ -<document source="test data"> - <paragraph> - Substitutions support case differences: - <substitution_definition name="eacute"> - \u00E9 - <substitution_definition name="Eacute"> - \u00C9 - <paragraph> - \u00C9 - t - \u00E9 - , and even \n\ - \u00C9 - . -"""], -]) - -totest['unicode'] = ((Substitutions,), [ -["""\ -Insert an em-dash (|mdash|), a copyright symbol (|copy|), a non-breaking -space (|nbsp|), a backwards-not-equals (|bne|), and a captial omega (|Omega|). - -.. |mdash| unicode:: 0x02014 -.. |copy| unicode:: \\u00A9 -.. |nbsp| unicode::   -.. |bne| unicode:: U0003D U020E5 -.. |Omega| unicode:: U+003A9 -""", -u"""\ -<document source="test data"> - <paragraph> - Insert an em-dash ( - \u2014 - ), a copyright symbol ( - \u00a9 - ), a non-breaking - space ( - \u00a0 - ), a backwards-not-equals ( - = - \u20e5 - ), and a captial omega ( - \u03a9 - ). - <substitution_definition name="mdash"> - \u2014 - <substitution_definition name="copy"> - \u00a9 - <substitution_definition name="nbsp"> - \u00a0 - <substitution_definition name="bne"> - = - \u20e5 - <substitution_definition name="Omega"> - \u03a9 -"""], -[""" -Testing comments and extra text. - -Copyright |copy| 2003, |BogusMegaCorp (TM)|. - -.. |copy| unicode:: 0xA9 .. copyright sign -.. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122 - .. with trademark sign -""", -u"""\ -<document source="test data"> - <paragraph> - Testing comments and extra text. - <paragraph> - Copyright \n\ - \u00a9 - 2003, \n\ - BogusMegaCorp - \u2122 - . - <substitution_definition name="copy"> - \u00a9 - <substitution_definition name="BogusMegaCorp (TM)"> - BogusMegaCorp - \u2122 -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') |
