summaryrefslogtreecommitdiff
path: root/docutils/test
diff options
context:
space:
mode:
author(no author) <(no author)@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2002-05-01 02:53:07 +0000
committer(no author) <(no author)@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2002-05-01 02:53:07 +0000
commit9e0c8b3997b83945c58c5ede77278f205b97d03e (patch)
tree5fdea7c382ce0fdcc49bc2bc0f9e8faaa7f4effc /docutils/test
parent6a5511292419427c9a4c9258b71c47d072a02878 (diff)
downloaddocutils-tibs.tar.gz
This commit was manufactured by cvs2svn to create branch 'tibs'.tibs
git-svn-id: http://svn.code.sf.net/p/docutils/code/branches/tibs@63 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/test')
-rw-r--r--docutils/test/DocutilsTestSupport.py399
-rwxr-xr-xdocutils/test/alltests.py65
-rw-r--r--docutils/test/difflib.py1089
-rw-r--r--docutils/test/package_unittest.py151
-rwxr-xr-xdocutils/test/test_nodes.py83
-rw-r--r--docutils/test/test_parsers/test_rst/__init__.py12
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_TableParser.py197
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_block_quotes.py124
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_bullet_lists.py181
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_citations.py139
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_comments.py238
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_definition_lists.py317
-rw-r--r--docutils/test/test_parsers/test_rst/test_directives/__init__.py12
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_directives/test_admonitions.py117
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_directives/test_contents.py166
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_directives/test_figures.py286
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_directives/test_images.py233
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_directives/test_meta.py141
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_directives/test_test_directives.py109
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_directives/test_unknown.py55
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_doctest_blocks.py74
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_enumerated_lists.py662
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_field_lists.py491
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_footnotes.py332
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_functions.py38
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_inline_markup.py756
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_literal_blocks.py190
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_option_lists.py684
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_outdenting.py90
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_paragraphs.py79
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_rfc2822.py260
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_section_headers.py555
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_substitutions.py192
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_tables.py564
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_targets.py429
-rwxr-xr-xdocutils/test/test_parsers/test_rst/test_transitions.py144
-rwxr-xr-xdocutils/test/test_statemachine.py296
-rw-r--r--docutils/test/test_transforms/__init__.py11
-rwxr-xr-xdocutils/test/test_transforms/test_contents.py262
-rwxr-xr-xdocutils/test/test_transforms/test_docinfo.py326
-rwxr-xr-xdocutils/test/test_transforms/test_doctitle.py174
-rwxr-xr-xdocutils/test/test_transforms/test_final_checks.py46
-rwxr-xr-xdocutils/test/test_transforms/test_footnotes.py520
-rwxr-xr-xdocutils/test/test_transforms/test_hyperlinks.py440
-rwxr-xr-xdocutils/test/test_transforms/test_messages.py66
-rwxr-xr-xdocutils/test/test_transforms/test_substitutions.py60
-rwxr-xr-xdocutils/test/test_utils.py324
47 files changed, 0 insertions, 12179 deletions
diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py
deleted file mode 100644
index 6fb710cd0..000000000
--- a/docutils/test/DocutilsTestSupport.py
+++ /dev/null
@@ -1,399 +0,0 @@
-#! /usr/bin/env python
-
-"""
-:Authors: David Goodger; Garth Kidd
-:Contact: goodger@users.sourceforge.net
-:Revision: $Revision$
-:Date: $Date$
-:Copyright: This module has been placed in the public domain.
-
-Exports the following:
-
-:Modules:
- - `statemachine` is 'docutils.statemachine'
- - `nodes` is 'docutils.nodes'
- - `urischemes` is 'docutils.urischemes'
- - `utils` is 'docutils.utils'
- - `transforms` is 'docutils.transforms'
- - `states` is 'docutils.parsers.rst.states'
- - `tableparser` is 'docutils.parsers.rst.tableparser'
-
-:Classes:
- - `CustomTestSuite`
- - `CustomTestCase`
- - `ParserTestSuite`
- - `ParserTestCase`
- - `TableParserTestSuite`
- - `TableParserTestCase`
-"""
-__docformat__ = 'reStructuredText'
-
-import package_unittest
-import sys, os, unittest, difflib, inspect, os, sys
-from pprint import pformat
-import docutils
-from docutils import statemachine, nodes, urischemes, utils, transforms
-from docutils.transforms import universal
-from docutils.parsers import rst
-from docutils.parsers.rst import states, tableparser, directives, languages
-from docutils.statemachine import string2lines
-
-try:
- import mypdb as pdb
-except:
- import pdb
-
-
-class CustomTestSuite(unittest.TestSuite):
-
- """
- A collection of custom TestCases.
-
- """
-
- id = ''
- """Identifier for the TestSuite. Prepended to the
- TestCase identifiers to make identification easier."""
-
- nextTestCaseId = 0
- """The next identifier to use for non-identified test cases."""
-
- def __init__(self, tests=(), id=None):
- """
- Initialize the CustomTestSuite.
-
- Arguments:
-
- id -- identifier for the suite, prepended to test cases.
- """
- unittest.TestSuite.__init__(self, tests)
- if id is None:
- outerframes = inspect.getouterframes(inspect.currentframe())
- mypath = outerframes[0][1]
- for outerframe in outerframes[1:]:
- if outerframe[3] != '__init__':
- callerpath = outerframe[1]
- break
- mydir, myname = os.path.split(mypath)
- if not mydir:
- mydir = os.curdir
- if callerpath.startswith(mydir):
- self.id = callerpath[len(mydir) + 1:] # caller's module
- else:
- self.id = callerpath
- else:
- self.id = id
-
- def addTestCase(self, testCaseClass, methodName, input, expected,
- id=None, runInDebugger=0, shortDescription=None,
- **kwargs):
- """
- Create a custom TestCase in the CustomTestSuite.
- Also return it, just in case.
-
- Arguments:
-
- testCaseClass --
- methodName --
- input -- input to the parser.
- expected -- expected output from the parser.
- id -- unique test identifier, used by the test framework.
- runInDebugger -- if true, run this test under the pdb debugger.
- shortDescription -- override to default test description.
- """
- if id is None: # generate id if required
- id = self.nextTestCaseId
- self.nextTestCaseId += 1
- # test identifier will become suiteid.testid
- tcid = '%s: %s' % (self.id, id)
- # generate and add test case
- tc = testCaseClass(methodName, input, expected, tcid,
- runInDebugger=runInDebugger,
- shortDescription=shortDescription,
- **kwargs)
- self.addTest(tc)
- return tc
-
-
-class CustomTestCase(unittest.TestCase):
-
- compare = difflib.Differ().compare
- """Comparison method shared by all subclasses."""
-
- def __init__(self, methodName, input, expected, id,
- runInDebugger=0, shortDescription=None):
- """
- Initialise the CustomTestCase.
-
- Arguments:
-
- methodName -- name of test method to run.
- input -- input to the parser.
- expected -- expected output from the parser.
- id -- unique test identifier, used by the test framework.
- runInDebugger -- if true, run this test under the pdb debugger.
- shortDescription -- override to default test description.
- """
- self.id = id
- self.input = input
- self.expected = expected
- self.runInDebugger = runInDebugger
- # Ring your mother.
- unittest.TestCase.__init__(self, methodName)
-
- def __str__(self):
- """
- Return string conversion. Overridden to give test id, in addition to
- method name.
- """
- return '%s; %s' % (self.id, unittest.TestCase.__str__(self))
-
- def __repr__(self):
- return "<%s %s>" % (self.id, unittest.TestCase.__repr__(self))
-
- def compareOutput(self, input, output, expected):
- """`input`, `output`, and `expected` should all be strings."""
- try:
- self.assertEquals('\n' + output, '\n' + expected)
- except AssertionError:
- print >>sys.stderr, '\n%s\ninput:' % (self,)
- print >>sys.stderr, input
- print >>sys.stderr, '-: expected\n+: output'
- print >>sys.stderr, ''.join(self.compare(expected.splitlines(1),
- output.splitlines(1)))
- raise
-
-
-class TransformTestSuite(CustomTestSuite):
-
- """
- A collection of TransformTestCases.
-
- A TransformTestSuite instance manufactures TransformTestCases,
- keeps track of them, and provides a shared test fixture (a-la
- setUp and tearDown).
- """
-
- def __init__(self, parser):
- self.parser = parser
- """Parser shared by all test cases."""
-
- CustomTestSuite.__init__(self)
-
- def generateTests(self, dict, dictname='totest',
- testmethod='test_transforms'):
- """
- Stock the suite with test cases generated from a test data dictionary.
-
- Each dictionary key (test type's name) maps to a list of transform
- classes and list of tests. Each test is a list: input, expected
- output, optional modifier. The optional third entry, a behavior
- modifier, can be 0 (temporarily disable this test) or 1 (run this test
- under the pdb debugger). Tests should be self-documenting and not
- require external comments.
- """
- for name, (transforms, cases) in dict.items():
- for casenum in range(len(cases)):
- case = cases[casenum]
- runInDebugger = 0
- if len(case)==3:
- if case[2]:
- runInDebugger = 1
- else:
- continue
- self.addTestCase(
- TransformTestCase, testmethod,
- transforms=transforms, parser=self.parser,
- input=case[0], expected=case[1],
- id='%s[%r][%s]' % (dictname, name, casenum),
- runInDebugger=runInDebugger)
-
-
-class TransformTestCase(CustomTestCase):
-
- """
- Output checker for the transform.
-
- Should probably be called TransformOutputChecker, but I can deal with
- that later when/if someone comes up with a category of transform test
- cases that have nothing to do with the input and output of the transform.
- """
-
- def __init__(self, *args, **kwargs):
- self.transforms = kwargs['transforms']
- """List of transforms to perform for this test case."""
-
- self.parser = kwargs['parser']
- """Input parser for this test case."""
-
- del kwargs['transforms'], kwargs['parser'] # only wanted here
- CustomTestCase.__init__(self, *args, **kwargs)
-
- def test_transforms(self):
- if self.runInDebugger:
- pdb.set_trace()
- doctree = utils.newdocument(warninglevel=5, errorlevel=5,
- debug=package_unittest.debug)
- self.parser.parse(self.input, doctree)
- for transformClass in (self.transforms + universal.test_transforms):
- transformClass(doctree).transform()
- output = doctree.pformat()
- self.compareOutput(self.input, output, self.expected)
-
- def test_transforms_verbosely(self):
- if self.runInDebugger:
- pdb.set_trace()
- print '\n', self.id
- print '-' * 70
- print self.input
- doctree = utils.newdocument(warninglevel=5, errorlevel=5,
- debug=package_unittest.debug)
- self.parser.parse(self.input, doctree)
- print '-' * 70
- print doctree.pformat()
- for transformClass in self.transforms:
- transformClass(doctree).transform()
- output = doctree.pformat()
- print '-' * 70
- print output
- self.compareOutput(self.input, output, self.expected)
-
-
-class ParserTestCase(CustomTestCase):
-
- """
- Output checker for the parser.
-
- Should probably be called ParserOutputChecker, but I can deal with
- that later when/if someone comes up with a category of parser test
- cases that have nothing to do with the input and output of the parser.
- """
-
- parser = rst.Parser()
- """Parser shared by all ParserTestCases."""
-
- def test_parser(self):
- if self.runInDebugger:
- pdb.set_trace()
- document = utils.newdocument(warninglevel=5, errorlevel=5,
- debug=package_unittest.debug)
- self.parser.parse(self.input, document)
- output = document.pformat()
- self.compareOutput(self.input, output, self.expected)
-
-
-class ParserTestSuite(CustomTestSuite):
-
- """
- A collection of ParserTestCases.
-
- A ParserTestSuite instance manufactures ParserTestCases,
- keeps track of them, and provides a shared test fixture (a-la
- setUp and tearDown).
- """
-
- test_case_class = ParserTestCase
-
- def generateTests(self, dict, dictname='totest'):
- """
- Stock the suite with test cases generated from a test data dictionary.
-
- Each dictionary key (test type name) maps to a list of tests. Each
- test is a list: input, expected output, optional modifier. The
- optional third entry, a behavior modifier, can be 0 (temporarily
- disable this test) or 1 (run this test under the pdb debugger). Tests
- should be self-documenting and not require external comments.
- """
- for name, cases in dict.items():
- for casenum in range(len(cases)):
- case = cases[casenum]
- runInDebugger = 0
- if len(case)==3:
- if case[2]:
- runInDebugger = 1
- else:
- continue
- self.addTestCase(
- self.test_case_class, 'test_parser',
- input=case[0], expected=case[1],
- id='%s[%r][%s]' % (dictname, name, casenum),
- runInDebugger=runInDebugger)
-
-
-class RFC2822ParserTestCase(ParserTestCase):
-
- """RFC2822-specific parser test case."""
-
- parser = rst.Parser(rfc2822=1)
- """Parser shared by all RFC2822ParserTestCases."""
-
-
-class RFC2822ParserTestSuite(ParserTestSuite):
-
- """A collection of RFC2822ParserTestCases."""
-
- test_case_class = RFC2822ParserTestCase
-
-
-class TableParserTestSuite(CustomTestSuite):
-
- """
- A collection of TableParserTestCases.
-
- A TableParserTestSuite instance manufactures TableParserTestCases,
- keeps track of them, and provides a shared test fixture (a-la
- setUp and tearDown).
- """
-
- def generateTests(self, dict, dictname='totest'):
- """
- Stock the suite with test cases generated from a test data dictionary.
-
- Each dictionary key (test type name) maps to a list of tests. Each
- test is a list: an input table, expected output from parsegrid(),
- expected output from parse(), optional modifier. The optional fourth
- entry, a behavior modifier, can be 0 (temporarily disable this test)
- or 1 (run this test under the pdb debugger). Tests should be
- self-documenting and not require external comments.
- """
- for name, cases in dict.items():
- for casenum in range(len(cases)):
- case = cases[casenum]
- runInDebugger = 0
- if len(case) == 4:
- if case[3]:
- runInDebugger = 1
- else:
- continue
- self.addTestCase(TableParserTestCase, 'test_parsegrid',
- input=case[0], expected=case[1],
- id='%s[%r][%s]' % (dictname, name, casenum),
- runInDebugger=runInDebugger)
- self.addTestCase(TableParserTestCase, 'test_parse',
- input=case[0], expected=case[2],
- id='%s[%r][%s]' % (dictname, name, casenum),
- runInDebugger=runInDebugger)
-
-
-class TableParserTestCase(CustomTestCase):
-
- parser = tableparser.TableParser()
-
- def test_parsegrid(self):
- self.parser.setup(string2lines(self.input))
- try:
- self.parser.findheadbodysep()
- self.parser.parsegrid()
- output = self.parser.cells
- except Exception, details:
- output = '%s: %s' % (details.__class__.__name__, details)
- self.compareOutput(self.input, pformat(output) + '\n',
- pformat(self.expected) + '\n')
-
- def test_parse(self):
- try:
- output = self.parser.parse(string2lines(self.input))
- except Exception, details:
- output = '%s: %s' % (details.__class__.__name__, details)
- self.compareOutput(self.input, pformat(output) + '\n',
- pformat(self.expected) + '\n')
diff --git a/docutils/test/alltests.py b/docutils/test/alltests.py
deleted file mode 100755
index a01a60ee5..000000000
--- a/docutils/test/alltests.py
+++ /dev/null
@@ -1,65 +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.
-
-All modules named 'test_*.py' in the current directory, and recursively in
-subdirectories (packages) called 'test_*', are loaded and test suites within
-are run.
-"""
-
-import time
-# Start point for actual elapsed time, including imports
-# and setup outside of unittest.
-start = time.time()
-
-import sys, os
-
-
-class Tee:
-
- """Write to a file and a stream (default: stdout) simultaneously."""
-
- def __init__(self, filename, stream=sys.__stdout__):
- self.file = open(filename, 'w')
- self.stream = stream
-
- def write(self, string):
- string = string.encode('raw-unicode-escape')
- self.stream.write(string)
- self.file.write(string)
-
-# must redirect stderr *before* first import of unittest
-sys.stdout = sys.stderr = Tee('alltests.out')
-
-
-def pformat(suite):
- step = 4
- suitestr = repr(suite).replace('=[<', '=[\n<').replace(', ', ',\n')
- indent = 0
- output = []
- for line in suitestr.splitlines():
- output.append(' ' * indent + line)
- if line[-1:] == '[':
- indent += step
- else:
- if line [-5:] == ']>]>,':
- indent -= step * 2
- elif line[-3:] == ']>,':
- indent -= step
- return '\n'.join(output)
-
-
-if __name__ == '__main__':
- import package_unittest
- path, script = os.path.split(sys.argv[0])
- suite = package_unittest.loadTestModules(path, 'test_', packages=1)
- package_unittest.main(suite)
- #if package_unittest.verbosity > 1:
- # print >>sys.stderr, pformat(suite) # check the test suite
- finish = time.time()
- print 'Elapsed time: %.3f seconds' % (finish - start)
diff --git a/docutils/test/difflib.py b/docutils/test/difflib.py
deleted file mode 100644
index a41d4d5ba..000000000
--- a/docutils/test/difflib.py
+++ /dev/null
@@ -1,1089 +0,0 @@
-#! /usr/bin/env python
-
-"""
-Module difflib -- helpers for computing deltas between objects.
-
-Function get_close_matches(word, possibilities, n=3, cutoff=0.6):
- Use SequenceMatcher to return list of the best "good enough" matches.
-
-Function ndiff(a, b):
- Return a delta: the difference between `a` and `b` (lists of strings).
-
-Function restore(delta, which):
- Return one of the two sequences that generated an ndiff delta.
-
-Class SequenceMatcher:
- A flexible class for comparing pairs of sequences of any type.
-
-Class Differ:
- For producing human-readable deltas from sequences of lines of text.
-"""
-
-__all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher',
- 'Differ']
-
-TRACE = 0
-
-class SequenceMatcher:
-
- """
- SequenceMatcher is a flexible class for comparing pairs of sequences of
- any type, so long as the sequence elements are hashable. The basic
- algorithm predates, and is a little fancier than, an algorithm
- published in the late 1980's by Ratcliff and Obershelp under the
- hyperbolic name "gestalt pattern matching". The basic idea is to find
- the longest contiguous matching subsequence that contains no "junk"
- elements (R-O doesn't address junk). The same idea is then applied
- recursively to the pieces of the sequences to the left and to the right
- of the matching subsequence. This does not yield minimal edit
- sequences, but does tend to yield matches that "look right" to people.
-
- SequenceMatcher tries to compute a "human-friendly diff" between two
- sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the
- longest *contiguous* & junk-free matching subsequence. That's what
- catches peoples' eyes. The Windows(tm) windiff has another interesting
- notion, pairing up elements that appear uniquely in each sequence.
- That, and the method here, appear to yield more intuitive difference
- reports than does diff. This method appears to be the least vulnerable
- to synching up on blocks of "junk lines", though (like blank lines in
- ordinary text files, or maybe "<P>" lines in HTML files). That may be
- because this is the only method of the 3 that has a *concept* of
- "junk" <wink>.
-
- Example, comparing two strings, and considering blanks to be "junk":
-
- >>> s = SequenceMatcher(lambda x: x == " ",
- ... "private Thread currentThread;",
- ... "private volatile Thread currentThread;")
- >>>
-
- .ratio() returns a float in [0, 1], measuring the "similarity" of the
- sequences. As a rule of thumb, a .ratio() value over 0.6 means the
- sequences are close matches:
-
- >>> print round(s.ratio(), 3)
- 0.866
- >>>
-
- If you're only interested in where the sequences match,
- .get_matching_blocks() is handy:
-
- >>> for block in s.get_matching_blocks():
- ... print "a[%d] and b[%d] match for %d elements" % block
- a[0] and b[0] match for 8 elements
- a[8] and b[17] match for 6 elements
- a[14] and b[23] match for 15 elements
- a[29] and b[38] match for 0 elements
-
- Note that the last tuple returned by .get_matching_blocks() is always a
- dummy, (len(a), len(b), 0), and this is the only case in which the last
- tuple element (number of elements matched) is 0.
-
- If you want to know how to change the first sequence into the second,
- use .get_opcodes():
-
- >>> for opcode in s.get_opcodes():
- ... print "%6s a[%d:%d] b[%d:%d]" % opcode
- equal a[0:8] b[0:8]
- insert a[8:8] b[8:17]
- equal a[8:14] b[17:23]
- equal a[14:29] b[23:38]
-
- See the Differ class for a fancy human-friendly file differencer, which
- uses SequenceMatcher both to compare sequences of lines, and to compare
- sequences of characters within similar (near-matching) lines.
-
- See also function get_close_matches() in this module, which shows how
- simple code building on SequenceMatcher can be used to do useful work.
-
- Timing: Basic R-O is cubic time worst case and quadratic time expected
- case. SequenceMatcher is quadratic time for the worst case and has
- expected-case behavior dependent in a complicated way on how many
- elements the sequences have in common; best case time is linear.
-
- Methods:
-
- __init__(isjunk=None, a='', b='')
- Construct a SequenceMatcher.
-
- set_seqs(a, b)
- Set the two sequences to be compared.
-
- set_seq1(a)
- Set the first sequence to be compared.
-
- set_seq2(b)
- Set the second sequence to be compared.
-
- find_longest_match(alo, ahi, blo, bhi)
- Find longest matching block in a[alo:ahi] and b[blo:bhi].
-
- get_matching_blocks()
- Return list of triples describing matching subsequences.
-
- get_opcodes()
- Return list of 5-tuples describing how to turn a into b.
-
- ratio()
- Return a measure of the sequences' similarity (float in [0,1]).
-
- quick_ratio()
- Return an upper bound on .ratio() relatively quickly.
-
- real_quick_ratio()
- Return an upper bound on ratio() very quickly.
- """
-
- def __init__(self, isjunk=None, a='', b=''):
- """Construct a SequenceMatcher.
-
- Optional arg isjunk is None (the default), or a one-argument
- function that takes a sequence element and returns true iff the
- element is junk. None is equivalent to passing "lambda x: 0", i.e.
- no elements are considered to be junk. For example, pass
- lambda x: x in " \\t"
- if you're comparing lines as sequences of characters, and don't
- want to synch up on blanks or hard tabs.
-
- Optional arg a is the first of two sequences to be compared. By
- default, an empty string. The elements of a must be hashable. See
- also .set_seqs() and .set_seq1().
-
- Optional arg b is the second of two sequences to be compared. By
- default, an empty string. The elements of b must be hashable. See
- also .set_seqs() and .set_seq2().
- """
-
- # Members:
- # a
- # first sequence
- # b
- # second sequence; differences are computed as "what do
- # we need to do to 'a' to change it into 'b'?"
- # b2j
- # for x in b, b2j[x] is a list of the indices (into b)
- # at which x appears; junk elements do not appear
- # b2jhas
- # b2j.has_key
- # fullbcount
- # for x in b, fullbcount[x] == the number of times x
- # appears in b; only materialized if really needed (used
- # only for computing quick_ratio())
- # matching_blocks
- # a list of (i, j, k) triples, where a[i:i+k] == b[j:j+k];
- # ascending & non-overlapping in i and in j; terminated by
- # a dummy (len(a), len(b), 0) sentinel
- # opcodes
- # a list of (tag, i1, i2, j1, j2) tuples, where tag is
- # one of
- # 'replace' a[i1:i2] should be replaced by b[j1:j2]
- # 'delete' a[i1:i2] should be deleted
- # 'insert' b[j1:j2] should be inserted
- # 'equal' a[i1:i2] == b[j1:j2]
- # isjunk
- # a user-supplied function taking a sequence element and
- # returning true iff the element is "junk" -- this has
- # subtle but helpful effects on the algorithm, which I'll
- # get around to writing up someday <0.9 wink>.
- # DON'T USE! Only __chain_b uses this. Use isbjunk.
- # isbjunk
- # for x in b, isbjunk(x) == isjunk(x) but much faster;
- # it's really the has_key method of a hidden dict.
- # DOES NOT WORK for x in a!
-
- self.isjunk = isjunk
- self.a = self.b = None
- self.set_seqs(a, b)
-
- def set_seqs(self, a, b):
- """Set the two sequences to be compared.
-
- >>> s = SequenceMatcher()
- >>> s.set_seqs("abcd", "bcde")
- >>> s.ratio()
- 0.75
- """
-
- self.set_seq1(a)
- self.set_seq2(b)
-
- def set_seq1(self, a):
- """Set the first sequence to be compared.
-
- The second sequence to be compared is not changed.
-
- >>> s = SequenceMatcher(None, "abcd", "bcde")
- >>> s.ratio()
- 0.75
- >>> s.set_seq1("bcde")
- >>> s.ratio()
- 1.0
- >>>
-
- SequenceMatcher computes and caches detailed information about the
- second sequence, so if you want to compare one sequence S against
- many sequences, use .set_seq2(S) once and call .set_seq1(x)
- repeatedly for each of the other sequences.
-
- See also set_seqs() and set_seq2().
- """
-
- if a is self.a:
- return
- self.a = a
- self.matching_blocks = self.opcodes = None
-
- def set_seq2(self, b):
- """Set the second sequence to be compared.
-
- The first sequence to be compared is not changed.
-
- >>> s = SequenceMatcher(None, "abcd", "bcde")
- >>> s.ratio()
- 0.75
- >>> s.set_seq2("abcd")
- >>> s.ratio()
- 1.0
- >>>
-
- SequenceMatcher computes and caches detailed information about the
- second sequence, so if you want to compare one sequence S against
- many sequences, use .set_seq2(S) once and call .set_seq1(x)
- repeatedly for each of the other sequences.
-
- See also set_seqs() and set_seq1().
- """
-
- if b is self.b:
- return
- self.b = b
- self.matching_blocks = self.opcodes = None
- self.fullbcount = None
- self.__chain_b()
-
- # For each element x in b, set b2j[x] to a list of the indices in
- # b where x appears; the indices are in increasing order; note that
- # the number of times x appears in b is len(b2j[x]) ...
- # when self.isjunk is defined, junk elements don't show up in this
- # map at all, which stops the central find_longest_match method
- # from starting any matching block at a junk element ...
- # also creates the fast isbjunk function ...
- # note that this is only called when b changes; so for cross-product
- # kinds of matches, it's best to call set_seq2 once, then set_seq1
- # repeatedly
-
- def __chain_b(self):
- # Because isjunk is a user-defined (not C) function, and we test
- # for junk a LOT, it's important to minimize the number of calls.
- # Before the tricks described here, __chain_b was by far the most
- # time-consuming routine in the whole module! If anyone sees
- # Jim Roskind, thank him again for profile.py -- I never would
- # have guessed that.
- # The first trick is to build b2j ignoring the possibility
- # of junk. I.e., we don't call isjunk at all yet. Throwing
- # out the junk later is much cheaper than building b2j "right"
- # from the start.
- b = self.b
- self.b2j = b2j = {}
- self.b2jhas = b2jhas = b2j.has_key
- for i in xrange(len(b)):
- elt = b[i]
- if b2jhas(elt):
- b2j[elt].append(i)
- else:
- b2j[elt] = [i]
-
- # Now b2j.keys() contains elements uniquely, and especially when
- # the sequence is a string, that's usually a good deal smaller
- # than len(string). The difference is the number of isjunk calls
- # saved.
- isjunk, junkdict = self.isjunk, {}
- if isjunk:
- for elt in b2j.keys():
- if isjunk(elt):
- junkdict[elt] = 1 # value irrelevant; it's a set
- del b2j[elt]
-
- # Now for x in b, isjunk(x) == junkdict.has_key(x), but the
- # latter is much faster. Note too that while there may be a
- # lot of junk in the sequence, the number of *unique* junk
- # elements is probably small. So the memory burden of keeping
- # this dict alive is likely trivial compared to the size of b2j.
- self.isbjunk = junkdict.has_key
-
- def find_longest_match(self, alo, ahi, blo, bhi):
- """Find longest matching block in a[alo:ahi] and b[blo:bhi].
-
- If isjunk is not defined:
-
- Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
- alo <= i <= i+k <= ahi
- blo <= j <= j+k <= bhi
- and for all (i',j',k') meeting those conditions,
- k >= k'
- i <= i'
- and if i == i', j <= j'
-
- In other words, of all maximal matching blocks, return one that
- starts earliest in a, and of all those maximal matching blocks that
- start earliest in a, return the one that starts earliest in b.
-
- >>> s = SequenceMatcher(None, " abcd", "abcd abcd")
- >>> s.find_longest_match(0, 5, 0, 9)
- (0, 4, 5)
-
- If isjunk is defined, first the longest matching block is
- determined as above, but with the additional restriction that no
- junk element appears in the block. Then that block is extended as
- far as possible by matching (only) junk elements on both sides. So
- the resulting block never matches on junk except as identical junk
- happens to be adjacent to an "interesting" match.
-
- Here's the same example as before, but considering blanks to be
- junk. That prevents " abcd" from matching the " abcd" at the tail
- end of the second sequence directly. Instead only the "abcd" can
- match, and matches the leftmost "abcd" in the second sequence:
-
- >>> s = SequenceMatcher(lambda x: x==" ", " abcd", "abcd abcd")
- >>> s.find_longest_match(0, 5, 0, 9)
- (1, 0, 4)
-
- If no blocks match, return (alo, blo, 0).
-
- >>> s = SequenceMatcher(None, "ab", "c")
- >>> s.find_longest_match(0, 2, 0, 1)
- (0, 0, 0)
- """
-
- # CAUTION: stripping common prefix or suffix would be incorrect.
- # E.g.,
- # ab
- # acab
- # Longest matching block is "ab", but if common prefix is
- # stripped, it's "a" (tied with "b"). UNIX(tm) diff does so
- # strip, so ends up claiming that ab is changed to acab by
- # inserting "ca" in the middle. That's minimal but unintuitive:
- # "it's obvious" that someone inserted "ac" at the front.
- # Windiff ends up at the same place as diff, but by pairing up
- # the unique 'b's and then matching the first two 'a's.
-
- a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.isbjunk
- besti, bestj, bestsize = alo, blo, 0
- # find longest junk-free match
- # during an iteration of the loop, j2len[j] = length of longest
- # junk-free match ending with a[i-1] and b[j]
- j2len = {}
- nothing = []
- for i in xrange(alo, ahi):
- # look at all instances of a[i] in b; note that because
- # b2j has no junk keys, the loop is skipped if a[i] is junk
- j2lenget = j2len.get
- newj2len = {}
- for j in b2j.get(a[i], nothing):
- # a[i] matches b[j]
- if j < blo:
- continue
- if j >= bhi:
- break
- k = newj2len[j] = j2lenget(j-1, 0) + 1
- if k > bestsize:
- besti, bestj, bestsize = i-k+1, j-k+1, k
- j2len = newj2len
-
- # Now that we have a wholly interesting match (albeit possibly
- # empty!), we may as well suck up the matching junk on each
- # side of it too. Can't think of a good reason not to, and it
- # saves post-processing the (possibly considerable) expense of
- # figuring out what to do with it. In the case of an empty
- # interesting match, this is clearly the right thing to do,
- # because no other kind of match is possible in the regions.
- while besti > alo and bestj > blo and \
- isbjunk(b[bestj-1]) and \
- a[besti-1] == b[bestj-1]:
- besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
- while besti+bestsize < ahi and bestj+bestsize < bhi and \
- isbjunk(b[bestj+bestsize]) and \
- a[besti+bestsize] == b[bestj+bestsize]:
- bestsize = bestsize + 1
-
- if TRACE:
- print "get_matching_blocks", alo, ahi, blo, bhi
- print " returns", besti, bestj, bestsize
- return besti, bestj, bestsize
-
- def get_matching_blocks(self):
- """Return list of triples describing matching subsequences.
-
- Each triple is of the form (i, j, n), and means that
- a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in
- i and in j.
-
- The last triple is a dummy, (len(a), len(b), 0), and is the only
- triple with n==0.
-
- >>> s = SequenceMatcher(None, "abxcd", "abcd")
- >>> s.get_matching_blocks()
- [(0, 0, 2), (3, 2, 2), (5, 4, 0)]
- """
-
- if self.matching_blocks is not None:
- return self.matching_blocks
- self.matching_blocks = []
- la, lb = len(self.a), len(self.b)
- self.__helper(0, la, 0, lb, self.matching_blocks)
- self.matching_blocks.append( (la, lb, 0) )
- if TRACE:
- print '*** matching blocks', self.matching_blocks
- return self.matching_blocks
-
- # builds list of matching blocks covering a[alo:ahi] and
- # b[blo:bhi], appending them in increasing order to answer
-
- def __helper(self, alo, ahi, blo, bhi, answer):
- i, j, k = x = self.find_longest_match(alo, ahi, blo, bhi)
- # a[alo:i] vs b[blo:j] unknown
- # a[i:i+k] same as b[j:j+k]
- # a[i+k:ahi] vs b[j+k:bhi] unknown
- if k:
- if alo < i and blo < j:
- self.__helper(alo, i, blo, j, answer)
- answer.append(x)
- if i+k < ahi and j+k < bhi:
- self.__helper(i+k, ahi, j+k, bhi, answer)
-
- def get_opcodes(self):
- """Return list of 5-tuples describing how to turn a into b.
-
- Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple
- has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
- tuple preceding it, and likewise for j1 == the previous j2.
-
- The tags are strings, with these meanings:
-
- 'replace': a[i1:i2] should be replaced by b[j1:j2]
- 'delete': a[i1:i2] should be deleted.
- Note that j1==j2 in this case.
- 'insert': b[j1:j2] should be inserted at a[i1:i1].
- Note that i1==i2 in this case.
- 'equal': a[i1:i2] == b[j1:j2]
-
- >>> a = "qabxcd"
- >>> b = "abycdf"
- >>> s = SequenceMatcher(None, a, b)
- >>> for tag, i1, i2, j1, j2 in s.get_opcodes():
- ... print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" %
- ... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2]))
- delete a[0:1] (q) b[0:0] ()
- equal a[1:3] (ab) b[0:2] (ab)
- replace a[3:4] (x) b[2:3] (y)
- equal a[4:6] (cd) b[3:5] (cd)
- insert a[6:6] () b[5:6] (f)
- """
-
- if self.opcodes is not None:
- return self.opcodes
- i = j = 0
- self.opcodes = answer = []
- for ai, bj, size in self.get_matching_blocks():
- # invariant: we've pumped out correct diffs to change
- # a[:i] into b[:j], and the next matching block is
- # a[ai:ai+size] == b[bj:bj+size]. So we need to pump
- # out a diff to change a[i:ai] into b[j:bj], pump out
- # the matching block, and move (i,j) beyond the match
- tag = ''
- if i < ai and j < bj:
- tag = 'replace'
- elif i < ai:
- tag = 'delete'
- elif j < bj:
- tag = 'insert'
- if tag:
- answer.append( (tag, i, ai, j, bj) )
- i, j = ai+size, bj+size
- # the list of matching blocks is terminated by a
- # sentinel with size 0
- if size:
- answer.append( ('equal', ai, i, bj, j) )
- return answer
-
- def ratio(self):
- """Return a measure of the sequences' similarity (float in [0,1]).
-
- Where T is the total number of elements in both sequences, and
- M is the number of matches, this is 2,0*M / T.
- Note that this is 1 if the sequences are identical, and 0 if
- they have nothing in common.
-
- .ratio() is expensive to compute if you haven't already computed
- .get_matching_blocks() or .get_opcodes(), in which case you may
- want to try .quick_ratio() or .real_quick_ratio() first to get an
- upper bound.
-
- >>> s = SequenceMatcher(None, "abcd", "bcde")
- >>> s.ratio()
- 0.75
- >>> s.quick_ratio()
- 0.75
- >>> s.real_quick_ratio()
- 1.0
- """
-
- matches = reduce(lambda sum, triple: sum + triple[-1],
- self.get_matching_blocks(), 0)
- return 2.0 * matches / (len(self.a) + len(self.b))
-
- def quick_ratio(self):
- """Return an upper bound on ratio() relatively quickly.
-
- This isn't defined beyond that it is an upper bound on .ratio(), and
- is faster to compute.
- """
-
- # viewing a and b as multisets, set matches to the cardinality
- # of their intersection; this counts the number of matches
- # without regard to order, so is clearly an upper bound
- if self.fullbcount is None:
- self.fullbcount = fullbcount = {}
- for elt in self.b:
- fullbcount[elt] = fullbcount.get(elt, 0) + 1
- fullbcount = self.fullbcount
- # avail[x] is the number of times x appears in 'b' less the
- # number of times we've seen it in 'a' so far ... kinda
- avail = {}
- availhas, matches = avail.has_key, 0
- for elt in self.a:
- if availhas(elt):
- numb = avail[elt]
- else:
- numb = fullbcount.get(elt, 0)
- avail[elt] = numb - 1
- if numb > 0:
- matches = matches + 1
- return 2.0 * matches / (len(self.a) + len(self.b))
-
- def real_quick_ratio(self):
- """Return an upper bound on ratio() very quickly.
-
- This isn't defined beyond that it is an upper bound on .ratio(), and
- is faster to compute than either .ratio() or .quick_ratio().
- """
-
- la, lb = len(self.a), len(self.b)
- # can't have more matches than the number of elements in the
- # shorter sequence
- return 2.0 * min(la, lb) / (la + lb)
-
-def get_close_matches(word, possibilities, n=3, cutoff=0.6):
- """Use SequenceMatcher to return list of the best "good enough" matches.
-
- word is a sequence for which close matches are desired (typically a
- string).
-
- possibilities is a list of sequences against which to match word
- (typically a list of strings).
-
- Optional arg n (default 3) is the maximum number of close matches to
- return. n must be > 0.
-
- Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities
- that don't score at least that similar to word are ignored.
-
- The best (no more than n) matches among the possibilities are returned
- in a list, sorted by similarity score, most similar first.
-
- >>> get_close_matches("appel", ["ape", "apple", "peach", "puppy"])
- ['apple', 'ape']
- >>> import keyword as _keyword
- >>> get_close_matches("wheel", _keyword.kwlist)
- ['while']
- >>> get_close_matches("apple", _keyword.kwlist)
- []
- >>> get_close_matches("accept", _keyword.kwlist)
- ['except']
- """
-
- if not n > 0:
- raise ValueError("n must be > 0: " + `n`)
- if not 0.0 <= cutoff <= 1.0:
- raise ValueError("cutoff must be in [0.0, 1.0]: " + `cutoff`)
- result = []
- s = SequenceMatcher()
- s.set_seq2(word)
- for x in possibilities:
- s.set_seq1(x)
- if s.real_quick_ratio() >= cutoff and \
- s.quick_ratio() >= cutoff and \
- s.ratio() >= cutoff:
- result.append((s.ratio(), x))
- # Sort by score.
- result.sort()
- # Retain only the best n.
- result = result[-n:]
- # Move best-scorer to head of list.
- result.reverse()
- # Strip scores.
- return [x for score, x in result]
-
-
-def _count_leading(line, ch):
- """
- Return number of `ch` characters at the start of `line`.
-
- Example:
-
- >>> _count_leading(' abc', ' ')
- 3
- """
-
- i, n = 0, len(line)
- while i < n and line[i] == ch:
- i += 1
- return i
-
-class Differ:
- r"""
- Differ is a class for comparing sequences of lines of text, and
- producing human-readable differences or deltas. Differ uses
- SequenceMatcher both to compare sequences of lines, and to compare
- sequences of characters within similar (near-matching) lines.
-
- Each line of a Differ delta begins with a two-letter code:
-
- '- ' line unique to sequence 1
- '+ ' line unique to sequence 2
- ' ' line common to both sequences
- '? ' line not present in either input sequence
-
- Lines beginning with '? ' attempt to guide the eye to intraline
- differences, and were not present in either input sequence. These lines
- can be confusing if the sequences contain tab characters.
-
- Note that Differ makes no claim to produce a *minimal* diff. To the
- contrary, minimal diffs are often counter-intuitive, because they synch
- up anywhere possible, sometimes accidental matches 100 pages apart.
- Restricting synch points to contiguous matches preserves some notion of
- locality, at the occasional cost of producing a longer diff.
-
- Example: Comparing two texts.
-
- First we set up the texts, sequences of individual single-line strings
- ending with newlines (such sequences can also be obtained from the
- `readlines()` method of file-like objects):
-
- >>> text1 = ''' 1. Beautiful is better than ugly.
- ... 2. Explicit is better than implicit.
- ... 3. Simple is better than complex.
- ... 4. Complex is better than complicated.
- ... '''.splitlines(1)
- >>> len(text1)
- 4
- >>> text1[0][-1]
- '\n'
- >>> text2 = ''' 1. Beautiful is better than ugly.
- ... 3. Simple is better than complex.
- ... 4. Complicated is better than complex.
- ... 5. Flat is better than nested.
- ... '''.splitlines(1)
-
- Next we instantiate a Differ object:
-
- >>> d = Differ()
-
- Note that when instantiating a Differ object we may pass functions to
- filter out line and character 'junk'. See Differ.__init__ for details.
-
- Finally, we compare the two:
-
- >>> result = d.compare(text1, text2)
-
- 'result' is a list of strings, so let's pretty-print it:
-
- >>> from pprint import pprint as _pprint
- >>> _pprint(result)
- [' 1. Beautiful is better than ugly.\n',
- '- 2. Explicit is better than implicit.\n',
- '- 3. Simple is better than complex.\n',
- '+ 3. Simple is better than complex.\n',
- '? ++\n',
- '- 4. Complex is better than complicated.\n',
- '? ^ ---- ^\n',
- '+ 4. Complicated is better than complex.\n',
- '? ++++ ^ ^\n',
- '+ 5. Flat is better than nested.\n']
-
- As a single multi-line string it looks like this:
-
- >>> print ''.join(result),
- 1. Beautiful is better than ugly.
- - 2. Explicit is better than implicit.
- - 3. Simple is better than complex.
- + 3. Simple is better than complex.
- ? ++
- - 4. Complex is better than complicated.
- ? ^ ---- ^
- + 4. Complicated is better than complex.
- ? ++++ ^ ^
- + 5. Flat is better than nested.
-
- Methods:
-
- __init__(linejunk=None, charjunk=None)
- Construct a text differencer, with optional filters.
-
- compare(a, b)
- Compare two sequences of lines; return the resulting delta (list).
- """
-
- def __init__(self, linejunk=None, charjunk=None):
- """
- Construct a text differencer, with optional filters.
-
- The two optional keyword parameters are for filter functions:
-
- - `linejunk`: A function that should accept a single string argument,
- and return true iff the string is junk. The module-level function
- `IS_LINE_JUNK` may be used to filter out lines without visible
- characters, except for at most one splat ('#').
-
- - `charjunk`: A function that should accept a string of length 1. The
- module-level function `IS_CHARACTER_JUNK` may be used to filter out
- whitespace characters (a blank or tab; **note**: bad idea to include
- newline in this!).
- """
-
- self.linejunk = linejunk
- self.charjunk = charjunk
- self.results = []
-
- def compare(self, a, b):
- r"""
- Compare two sequences of lines; return the resulting delta (list).
-
- Each sequence must contain individual single-line strings ending with
- newlines. Such sequences can be obtained from the `readlines()` method
- of file-like objects. The list returned is also made up of
- newline-terminated strings, ready to be used with the `writelines()`
- method of a file-like object.
-
- Example:
-
- >>> print ''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1),
- ... 'ore\ntree\nemu\n'.splitlines(1))),
- - one
- ? ^
- + ore
- ? ^
- - two
- - three
- ? -
- + tree
- + emu
- """
-
- cruncher = SequenceMatcher(self.linejunk, a, b)
- for tag, alo, ahi, blo, bhi in cruncher.get_opcodes():
- if tag == 'replace':
- self._fancy_replace(a, alo, ahi, b, blo, bhi)
- elif tag == 'delete':
- self._dump('-', a, alo, ahi)
- elif tag == 'insert':
- self._dump('+', b, blo, bhi)
- elif tag == 'equal':
- self._dump(' ', a, alo, ahi)
- else:
- raise ValueError, 'unknown tag ' + `tag`
- results = self.results
- self.results = []
- return results
-
- def _dump(self, tag, x, lo, hi):
- """Store comparison results for a same-tagged range."""
- for i in xrange(lo, hi):
- self.results.append('%s %s' % (tag, x[i]))
-
- def _plain_replace(self, a, alo, ahi, b, blo, bhi):
- assert alo < ahi and blo < bhi
- # dump the shorter block first -- reduces the burden on short-term
- # memory if the blocks are of very different sizes
- if bhi - blo < ahi - alo:
- self._dump('+', b, blo, bhi)
- self._dump('-', a, alo, ahi)
- else:
- self._dump('-', a, alo, ahi)
- self._dump('+', b, blo, bhi)
-
- def _fancy_replace(self, a, alo, ahi, b, blo, bhi):
- r"""
- When replacing one block of lines with another, search the blocks
- for *similar* lines; the best-matching pair (if any) is used as a
- synch point, and intraline difference marking is done on the
- similar pair. Lots of work, but often worth it.
-
- Example:
-
- >>> d = Differ()
- >>> d._fancy_replace(['abcDefghiJkl\n'], 0, 1, ['abcdefGhijkl\n'], 0, 1)
- >>> print ''.join(d.results),
- - abcDefghiJkl
- ? ^ ^ ^
- + abcdefGhijkl
- ? ^ ^ ^
- """
-
- if TRACE:
- self.results.append('*** _fancy_replace %s %s %s %s\n'
- % (alo, ahi, blo, bhi))
- self._dump('>', a, alo, ahi)
- self._dump('<', b, blo, bhi)
-
- # don't synch up unless the lines have a similarity score of at
- # least cutoff; best_ratio tracks the best score seen so far
- best_ratio, cutoff = 0.74, 0.75
- cruncher = SequenceMatcher(self.charjunk)
- eqi, eqj = None, None # 1st indices of equal lines (if any)
-
- # search for the pair that matches best without being identical
- # (identical lines must be junk lines, & we don't want to synch up
- # on junk -- unless we have to)
- for j in xrange(blo, bhi):
- bj = b[j]
- cruncher.set_seq2(bj)
- for i in xrange(alo, ahi):
- ai = a[i]
- if ai == bj:
- if eqi is None:
- eqi, eqj = i, j
- continue
- cruncher.set_seq1(ai)
- # computing similarity is expensive, so use the quick
- # upper bounds first -- have seen this speed up messy
- # compares by a factor of 3.
- # note that ratio() is only expensive to compute the first
- # time it's called on a sequence pair; the expensive part
- # of the computation is cached by cruncher
- if cruncher.real_quick_ratio() > best_ratio and \
- cruncher.quick_ratio() > best_ratio and \
- cruncher.ratio() > best_ratio:
- best_ratio, best_i, best_j = cruncher.ratio(), i, j
- if best_ratio < cutoff:
- # no non-identical "pretty close" pair
- if eqi is None:
- # no identical pair either -- treat it as a straight replace
- self._plain_replace(a, alo, ahi, b, blo, bhi)
- return
- # no close pair, but an identical pair -- synch up on that
- best_i, best_j, best_ratio = eqi, eqj, 1.0
- else:
- # there's a close pair, so forget the identical pair (if any)
- eqi = None
-
- # a[best_i] very similar to b[best_j]; eqi is None iff they're not
- # identical
- if TRACE:
- self.results.append('*** best_ratio %s %s %s %s\n'
- % (best_ratio, best_i, best_j))
- self._dump('>', a, best_i, best_i+1)
- self._dump('<', b, best_j, best_j+1)
-
- # pump out diffs from before the synch point
- self._fancy_helper(a, alo, best_i, b, blo, best_j)
-
- # do intraline marking on the synch pair
- aelt, belt = a[best_i], b[best_j]
- if eqi is None:
- # pump out a '-', '?', '+', '?' quad for the synched lines
- atags = btags = ""
- cruncher.set_seqs(aelt, belt)
- for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes():
- la, lb = ai2 - ai1, bj2 - bj1
- if tag == 'replace':
- atags += '^' * la
- btags += '^' * lb
- elif tag == 'delete':
- atags += '-' * la
- elif tag == 'insert':
- btags += '+' * lb
- elif tag == 'equal':
- atags += ' ' * la
- btags += ' ' * lb
- else:
- raise ValueError, 'unknown tag ' + `tag`
- self._qformat(aelt, belt, atags, btags)
- else:
- # the synch pair is identical
- self.results.append(' ' + aelt)
-
- # pump out diffs from after the synch point
- self._fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi)
-
- def _fancy_helper(self, a, alo, ahi, b, blo, bhi):
- if alo < ahi:
- if blo < bhi:
- self._fancy_replace(a, alo, ahi, b, blo, bhi)
- else:
- self._dump('-', a, alo, ahi)
- elif blo < bhi:
- self._dump('+', b, blo, bhi)
-
- def _qformat(self, aline, bline, atags, btags):
- r"""
- Format "?" output and deal with leading tabs.
-
- Example:
-
- >>> d = Differ()
- >>> d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n',
- ... ' ^ ^ ^ ', '+ ^ ^ ^ ')
- >>> for line in d.results: print repr(line)
- ...
- '- \tabcDefghiJkl\n'
- '? \t ^ ^ ^\n'
- '+ \t\tabcdefGhijkl\n'
- '? \t ^ ^ ^\n'
- """
-
- # Can hurt, but will probably help most of the time.
- common = min(_count_leading(aline, "\t"),
- _count_leading(bline, "\t"))
- common = min(common, _count_leading(atags[:common], " "))
- atags = atags[common:].rstrip()
- btags = btags[common:].rstrip()
-
- self.results.append("- " + aline)
- if atags:
- self.results.append("? %s%s\n" % ("\t" * common, atags))
-
- self.results.append("+ " + bline)
- if btags:
- self.results.append("? %s%s\n" % ("\t" * common, btags))
-
-# With respect to junk, an earlier version of ndiff simply refused to
-# *start* a match with a junk element. The result was cases like this:
-# before: private Thread currentThread;
-# after: private volatile Thread currentThread;
-# If you consider whitespace to be junk, the longest contiguous match
-# not starting with junk is "e Thread currentThread". So ndiff reported
-# that "e volatil" was inserted between the 't' and the 'e' in "private".
-# While an accurate view, to people that's absurd. The current version
-# looks for matching blocks that are entirely junk-free, then extends the
-# longest one of those as far as possible but only with matching junk.
-# So now "currentThread" is matched, then extended to suck up the
-# preceding blank; then "private" is matched, and extended to suck up the
-# following blank; then "Thread" is matched; and finally ndiff reports
-# that "volatile " was inserted before "Thread". The only quibble
-# remaining is that perhaps it was really the case that " volatile"
-# was inserted after "private". I can live with that <wink>.
-
-import re
-
-def IS_LINE_JUNK(line, pat=re.compile(r"\s*#?\s*$").match):
- r"""
- Return 1 for ignorable line: iff `line` is blank or contains a single '#'.
-
- Examples:
-
- >>> IS_LINE_JUNK('\n')
- 1
- >>> IS_LINE_JUNK(' # \n')
- 1
- >>> IS_LINE_JUNK('hello\n')
- 0
- """
-
- return pat(line) is not None
-
-def IS_CHARACTER_JUNK(ch, ws=" \t"):
- r"""
- Return 1 for ignorable character: iff `ch` is a space or tab.
-
- Examples:
-
- >>> IS_CHARACTER_JUNK(' ')
- 1
- >>> IS_CHARACTER_JUNK('\t')
- 1
- >>> IS_CHARACTER_JUNK('\n')
- 0
- >>> IS_CHARACTER_JUNK('x')
- 0
- """
-
- return ch in ws
-
-del re
-
-def ndiff(a, b, linejunk=IS_LINE_JUNK, charjunk=IS_CHARACTER_JUNK):
- r"""
- Compare `a` and `b` (lists of strings); return a `Differ`-style delta.
-
- Optional keyword parameters `linejunk` and `charjunk` are for filter
- functions (or None):
-
- - linejunk: A function that should accept a single string argument, and
- return true iff the string is junk. The default is module-level function
- IS_LINE_JUNK, which filters out lines without visible characters, except
- for at most one splat ('#').
-
- - charjunk: A function that should accept a string of length 1. The
- default is module-level function IS_CHARACTER_JUNK, which filters out
- whitespace characters (a blank or tab; note: bad idea to include newline
- in this!).
-
- Tools/scripts/ndiff.py is a command-line front-end to this function.
-
- Example:
-
- >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1),
- ... 'ore\ntree\nemu\n'.splitlines(1))
- >>> print ''.join(diff),
- - one
- ? ^
- + ore
- ? ^
- - two
- - three
- ? -
- + tree
- + emu
- """
- return Differ(linejunk, charjunk).compare(a, b)
-
-def restore(delta, which):
- r"""
- Return one of the two sequences that generated a delta.
-
- Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract
- lines originating from file 1 or 2 (parameter `which`), stripping off line
- prefixes.
-
- Examples:
-
- >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1),
- ... 'ore\ntree\nemu\n'.splitlines(1))
- >>> print ''.join(restore(diff, 1)),
- one
- two
- three
- >>> print ''.join(restore(diff, 2)),
- ore
- tree
- emu
- """
- try:
- tag = {1: "- ", 2: "+ "}[int(which)]
- except KeyError:
- raise ValueError, ('unknown delta choice (must be 1 or 2): %r'
- % which)
- prefixes = (" ", tag)
- results = []
- for line in delta:
- if line[:2] in prefixes:
- results.append(line[2:])
- return results
-
-def _test():
- import doctest, difflib
- return doctest.testmod(difflib)
-
-if __name__ == "__main__":
- _test()
diff --git a/docutils/test/package_unittest.py b/docutils/test/package_unittest.py
deleted file mode 100644
index 32ced69c2..000000000
--- a/docutils/test/package_unittest.py
+++ /dev/null
@@ -1,151 +0,0 @@
-#! /usr/bin/env python
-
-"""
-:Author: Garth Kidd
-:Contact: garth@deadlybloodyserious.com
-:Revision: $Revision$
-:Date: $Date$
-:Copyright: This module has been placed in the public domain.
-
-This module extends unittest.py with `loadTestModules()`, by loading multiple
-test modules from a directory. Optionally, test packages are also loaded,
-recursively.
-"""
-
-import sys, os, getopt, types, unittest, re
-
-
-# So that individual test modules can share a bit of state,
-# `package_unittest` acts as an intermediary for the following
-# variables:
-debug = 0
-verbosity = 1
-
-USAGE = """\
-Usage: test_whatever [options]
-
-Options:
- -h, --help Show this message
- -v, --verbose Verbose output
- -q, --quiet Minimal output
- -d, --debug Debug mode
-"""
-
-def usageExit(msg=None):
- """Print usage and exit."""
- if msg:
- print msg
- print USAGE
- sys.exit(2)
-
-def parseArgs(argv=sys.argv):
- """Parse command line arguments and set TestFramework state.
-
- State is to be acquired by test_* modules by a grotty hack:
- ``from TestFramework import *``. For this stylistic
- transgression, I expect to be first up against the wall
- when the revolution comes. --Garth"""
- global verbosity, debug
- try:
- options, args = getopt.getopt(argv[1:], 'hHvqd',
- ['help', 'verbose', 'quiet', 'debug'])
- for opt, value in options:
- if opt in ('-h', '-H', '--help'):
- usageExit()
- if opt in ('-q', '--quiet'):
- verbosity = 0
- if opt in ('-v', '--verbose'):
- verbosity = 2
- if opt in ('-d', '--debug'):
- debug =1
- if len(args) != 0:
- usageExit("No command-line arguments supported yet.")
- except getopt.error, msg:
- self.usageExit(msg)
-
-def loadTestModules(path, name='', packages=None):
- """
- Return a test suite composed of all the tests from modules in a directory.
-
- Search for modules in directory `path`, beginning with `name`. If
- `packages` is true, search subdirectories (also beginning with `name`)
- recursively. Subdirectories must be Python packages; they must contain an
- '__init__.py' module.
- """
- testLoader = unittest.defaultTestLoader
- testSuite = unittest.TestSuite()
- testModules = []
- paths = [path]
- while paths:
- p = paths.pop(0)
- if not p:
- p = os.curdir
- files = os.listdir(p)
- for filename in files:
- if filename.startswith(name):
- fullpath = os.path.join(p, filename)
- if filename.endswith('.py'):
- testModules.append(path2mod(fullpath[len(path)+1:]))
- elif packages and os.path.isdir(fullpath) and \
- os.path.isfile(os.path.join(fullpath, '__init__.py')):
- paths.append(fullpath)
- # Import modules and add their tests to the suite.
- sys.path.insert(0, path)
- for mod in testModules:
- if debug:
- print >>sys.stderr, "importing %s" % mod
- module = import_module(mod)
- # if there's a suite defined, incorporate its contents
- try:
- suite = getattr(module, 'suite')
- except AttributeError:
- # Look for individual tests
- moduleTests = testLoader.loadTestsFromModule(module)
- # unittest.TestSuite.addTests() doesn't work as advertised,
- # as it can't load tests from another TestSuite, so we have
- # to cheat:
- testSuite.addTest(moduleTests)
- continue
- if type(suite) == types.FunctionType:
- testSuite.addTest(suite())
- elif type(suite) == types.InstanceType \
- and isinstance(suite, unittest.TestSuite):
- testSuite.addTest(suite)
- else:
- raise AssertionError, "don't understand suite (%s)" % mod
- sys.path.pop(0)
- return testSuite
-
-def path2mod(path):
- """Convert a file path to a dotted module name."""
- return path[:-3].replace(os.sep, '.')
-
-def import_module(name):
- """Import a dotted-path module name, and return the final component."""
- mod = __import__(name)
- components = name.split('.')
- for comp in components[1:]:
- mod = getattr(mod, comp)
- return mod
-
-def main(suite=None):
- """
- Shared `main` for any individual test_* file.
-
- suite -- TestSuite to run. If not specified, look for any globally defined
- tests and run them.
- """
- parseArgs()
- if suite is None:
- # Load any globally defined tests.
- suite = unittest.defaultTestLoader.loadTestsFromModule(
- __import__('__main__'))
- if debug:
- print >>sys.stderr, "Debug: Suite=%s" % suite
- testRunner = unittest.TextTestRunner(verbosity=verbosity)
- # run suites (if we were called from test_all) or suite...
- if type(suite) == type([]):
- for s in suite:
- testRunner.run(s)
- else:
- testRunner.run(suite)
diff --git a/docutils/test/test_nodes.py b/docutils/test/test_nodes.py
deleted file mode 100755
index 15e633357..000000000
--- a/docutils/test/test_nodes.py
+++ /dev/null
@@ -1,83 +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.
-
-Test module for nodes.py.
-"""
-
-import unittest
-from DocutilsTestSupport import nodes
-
-debug = 0
-
-
-class TextTests(unittest.TestCase):
-
- def setUp(self):
- self.text = nodes.Text('Line 1.\nLine 2.')
-
- def test_repr(self):
- self.assertEquals(repr(self.text), r"<#text: 'Line 1.\nLine 2.'>")
-
- def test_str(self):
- self.assertEquals(str(self.text), 'Line 1.\nLine 2.')
-
- def test_asdom(self):
- dom = self.text.asdom()
- self.assertEquals(dom.toxml(), 'Line 1.\nLine 2.')
- dom.unlink()
-
- def test_astext(self):
- self.assertEquals(self.text.astext(), 'Line 1.\nLine 2.')
-
- def test_pformat(self):
- self.assertEquals(self.text.pformat(), 'Line 1.\nLine 2.\n')
-
-
-class ElementTests(unittest.TestCase):
-
- def test_empty(self):
- element = nodes.Element()
- self.assertEquals(repr(element), '<Element: >')
- self.assertEquals(str(element), '<Element/>')
- dom = element.asdom()
- self.assertEquals(dom.toxml(), '<Element/>')
- dom.unlink()
- element['attr'] = '1'
- self.assertEquals(repr(element), '<Element: >')
- self.assertEquals(str(element), '<Element attr="1"/>')
- dom = element.asdom()
- self.assertEquals(dom.toxml(), '<Element attr="1"/>')
- dom.unlink()
- self.assertEquals(element.pformat(), '<Element attr="1">\n')
-
- def test_withtext(self):
- element = nodes.Element('text\nmore', nodes.Text('text\nmore'))
- self.assertEquals(repr(element), r"<Element: <#text: 'text\nmore'>>")
- self.assertEquals(str(element), '<Element>text\nmore</Element>')
- dom = element.asdom()
- self.assertEquals(dom.toxml(), '<Element>text\nmore</Element>')
- dom.unlink()
- element['attr'] = '1'
- self.assertEquals(repr(element), r"<Element: <#text: 'text\nmore'>>")
- self.assertEquals(str(element),
- '<Element attr="1">text\nmore</Element>')
- dom = element.asdom()
- self.assertEquals(dom.toxml(),
- '<Element attr="1">text\nmore</Element>')
- dom.unlink()
- self.assertEquals(element.pformat(),
-"""\
-<Element attr="1">
- text
- more
-""")
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/docutils/test/test_parsers/test_rst/__init__.py b/docutils/test/test_parsers/test_rst/__init__.py
deleted file mode 100644
index 8df5d4778..000000000
--- a/docutils/test/test_parsers/test_rst/__init__.py
+++ /dev/null
@@ -1,12 +0,0 @@
-import os, os.path, 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_parsers/test_rst/test_TableParser.py b/docutils/test/test_parsers/test_rst/test_TableParser.py
deleted file mode 100755
index d79c2c58d..000000000
--- a/docutils/test/test_parsers/test_rst/test_TableParser.py
+++ /dev/null
@@ -1,197 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.TableParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['tables'] = [
-["""\
-+-------------------------------------+
-| A table with one cell and one line. |
-+-------------------------------------+
-""",
-[(0, 0, 2, 38, ['A table with one cell and one line.'])],
-([37],
- [],
- [[(0, 0, 1, ['A table with one cell and one line.'])]])],
-["""\
-+--------------+--------------+
-| A table with | two columns. |
-+--------------+--------------+
-""",
-[(0, 0, 2, 15, ['A table with']),
- (0, 15, 2, 30, ['two columns.'])],
-([14, 14],
- [],
- [[(0, 0, 1, ['A table with']),
- (0, 0, 1, ['two columns.'])]])],
-["""\
-+--------------+-------------+
-| A table with | two columns |
-+--------------+-------------+
-| and | two rows. |
-+--------------+-------------+
-""",
-[(0, 0, 2, 15, ['A table with']),
- (0, 15, 2, 29, ['two columns']),
- (2, 0, 4, 15, ['and']),
- (2, 15, 4, 29, ['two rows.'])],
-([14, 13],
- [],
- [[(0, 0, 1, ['A table with']),
- (0, 0, 1, ['two columns'])],
- [(0, 0, 3, ['and']),
- (0, 0, 3, ['two rows.'])]])],
-["""\
-+--------------------------+
-| A table with three rows, |
-+------------+-------------+
-| and two | columns. |
-+------------+-------------+
-| First and last rows |
-| contain column spans. |
-+--------------------------+
-""",
-[(0, 0, 2, 27, ['A table with three rows,']),
- (2, 0, 4, 13, ['and two']),
- (2, 13, 4, 27, ['columns.']),
- (4, 0, 7, 27, ['First and last rows', 'contain column spans.'])],
-([12, 13],
- [],
- [[(0, 1, 1, ['A table with three rows,']),
- None],
- [(0, 0, 3, ['and two']),
- (0, 0, 3, ['columns.'])],
- [(0, 1, 5, ['First and last rows', 'contain column spans.']),
- None]])],
-["""\
-+------------+-------------+---------------+
-| A table | two rows in | and row spans |
-| with three +-------------+ to left and |
-| columns, | the middle, | right. |
-+------------+-------------+---------------+
-""",
-[(0, 0, 4, 13, ['A table', 'with three', 'columns,']),
- (0, 13, 2, 27, ['two rows in']),
- (0, 27, 4, 43, ['and row spans', 'to left and', 'right.']),
- (2, 13, 4, 27, ['the middle,'])],
-([12, 13, 15],
- [],
- [[(1, 0, 1, ['A table', 'with three', 'columns,']),
- (0, 0, 1, ['two rows in']),
- (1, 0, 1, ['and row spans', 'to left and', 'right.'])],
- [None,
- (0, 0, 3, ['the middle,']),
- None]])],
-["""\
-+------------+-------------+---------------+
-| A table | | two rows in | and funny |
-| with 3 +--+-------------+-+ stuff. |
-| columns, | the middle, | | |
-+------------+-------------+---------------+
-""",
-[(0, 0, 4, 13, ['A table |', 'with 3 +--', 'columns,']),
- (0, 13, 2, 27, ['two rows in']),
- (0, 27, 4, 43, [' and funny', '-+ stuff.', ' |']),
- (2, 13, 4, 27, ['the middle,'])],
-([12, 13, 15],
- [],
- [[(1, 0, 1, ['A table |', 'with 3 +--', 'columns,']),
- (0, 0, 1, ['two rows in']),
- (1, 0, 1, [' and funny', '-+ stuff.', ' |'])],
- [None,
- (0, 0, 3, ['the middle,']),
- None]])],
-["""\
-+-----------+-------------------------+
-| W/NW cell | N/NE cell |
-| +-------------+-----------+
-| | Middle cell | E/SE cell |
-+-----------+-------------+ |
-| S/SE cell | |
-+-------------------------+-----------+
-""",
-[(0, 0, 4, 12, ['W/NW cell', '', '']),
- (0, 12, 2, 38, ['N/NE cell']),
- (2, 12, 4, 26, ['Middle cell']),
- (2, 26, 6, 38, ['E/SE cell', '', '']),
- (4, 0, 6, 26, ['S/SE cell'])],
-([11, 13, 11],
- [],
- [[(1, 0, 1, ['W/NW cell', '', '']),
- (0, 1, 1, ['N/NE cell']),
- None],
- [None,
- (0, 0, 3, ['Middle cell']),
- (1, 0, 3, ['E/SE cell', '', ''])],
- [(0, 1, 5, ['S/SE cell']),
- None,
- None]])],
-["""\
-+--------------+-------------+
-| A bad table. | |
-+--------------+ |
-| Cells must be rectangles. |
-+----------------------------+
-""",
-'TableMarkupError: Malformed table; parse incomplete.',
-'TableMarkupError: Malformed table; parse incomplete.'],
-["""\
-+-------------------------------+
-| A table with two header rows, |
-+------------+------------------+
-| the first | with a span. |
-+============+==================+
-| Two body | rows, |
-+------------+------------------+
-| the second with a span. |
-+-------------------------------+
-""",
-[(0, 0, 2, 32, ['A table with two header rows,']),
- (2, 0, 4, 13, ['the first']),
- (2, 13, 4, 32, ['with a span.']),
- (4, 0, 6, 13, ['Two body']),
- (4, 13, 6, 32, ['rows,']),
- (6, 0, 8, 32, ['the second with a span.'])],
-([12, 18],
- [[(0, 1, 1, ['A table with two header rows,']),
- None],
- [(0, 0, 3, ['the first']),
- (0, 0, 3, ['with a span.'])]],
- [[(0, 0, 5, ['Two body']),
- (0, 0, 5, ['rows,'])],
- [(0, 1, 7, ['the second with a span.']),
- None]])],
-["""\
-+-------------------------------+
-| A table with two head/body |
-+=============+=================+
-| row | separators. |
-+=============+=================+
-| That's bad. | |
-+-------------+-----------------+
-""",
-'TableMarkupError: Multiple head/body row separators in table '
-'(at line offset 2 and 4); only one allowed.',
-'TableMarkupError: Multiple head/body row separators in table '
-'(at line offset 2 and 4); only one allowed.'],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_block_quotes.py b/docutils/test/test_parsers/test_rst/test_block_quotes.py
deleted file mode 100755
index 9ef810972..000000000
--- a/docutils/test/test_parsers/test_rst/test_block_quotes.py
+++ /dev/null
@@ -1,124 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['block_quotes'] = [
-["""\
-Line 1.
-Line 2.
-
- Indented.
-""",
-"""\
-<document>
- <paragraph>
- Line 1.
- Line 2.
- <block_quote>
- <paragraph>
- Indented.
-"""],
-["""\
-Line 1.
-Line 2.
-
- Indented 1.
-
- Indented 2.
-""",
-"""\
-<document>
- <paragraph>
- Line 1.
- Line 2.
- <block_quote>
- <paragraph>
- Indented 1.
- <block_quote>
- <paragraph>
- Indented 2.
-"""],
-["""\
-Line 1.
-Line 2.
- Unexpectedly indented.
-""",
-"""\
-<document>
- <paragraph>
- Line 1.
- Line 2.
- <system_message level="3" type="ERROR">
- <paragraph>
- Unexpected indentation at line 3.
- <block_quote>
- <paragraph>
- Unexpectedly indented.
-"""],
-["""\
-Line 1.
-Line 2.
-
- Indented.
-no blank line
-""",
-"""\
-<document>
- <paragraph>
- Line 1.
- Line 2.
- <block_quote>
- <paragraph>
- Indented.
- <system_message level="2" type="WARNING">
- <paragraph>
- Block quote ends without a blank line; unexpected unindent at line 5.
- <paragraph>
- no blank line
-"""],
-["""\
-Here is a paragraph.
-
- Indent 8 spaces.
-
- Indent 4 spaces.
-
-Is this correct? Should it generate a warning?
-Yes, it is correct, no warning necessary.
-""",
-"""\
-<document>
- <paragraph>
- Here is a paragraph.
- <block_quote>
- <block_quote>
- <paragraph>
- Indent 8 spaces.
- <paragraph>
- Indent 4 spaces.
- <paragraph>
- Is this correct? Should it generate a warning?
- Yes, it is correct, no warning necessary.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_bullet_lists.py b/docutils/test/test_parsers/test_rst/test_bullet_lists.py
deleted file mode 100755
index 61049ae8a..000000000
--- a/docutils/test/test_parsers/test_rst/test_bullet_lists.py
+++ /dev/null
@@ -1,181 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['bullet_lists'] = [
-["""\
-- item
-""",
-"""\
-<document>
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- item
-"""],
-["""\
-* item 1
-
-* item 2
-""",
-"""\
-<document>
- <bullet_list bullet="*">
- <list_item>
- <paragraph>
- item 1
- <list_item>
- <paragraph>
- item 2
-"""],
-["""\
-No blank line between:
-
-+ item 1
-+ item 2
-""",
-"""\
-<document>
- <paragraph>
- No blank line between:
- <bullet_list bullet="+">
- <list_item>
- <paragraph>
- item 1
- <list_item>
- <paragraph>
- item 2
-"""],
-["""\
-- item 1, para 1.
-
- item 1, para 2.
-
-- item 2
-""",
-"""\
-<document>
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- item 1, para 1.
- <paragraph>
- item 1, para 2.
- <list_item>
- <paragraph>
- item 2
-"""],
-["""\
-- item 1, line 1
- item 1, line 2
-- item 2
-""",
-"""\
-<document>
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- item 1, line 1
- item 1, line 2
- <list_item>
- <paragraph>
- item 2
-"""],
-["""\
-Different bullets:
-
-- item 1
-
-+ item 2
-
-* item 3
-- item 4
-""",
-"""\
-<document>
- <paragraph>
- Different bullets:
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- item 1
- <bullet_list bullet="+">
- <list_item>
- <paragraph>
- item 2
- <bullet_list bullet="*">
- <list_item>
- <paragraph>
- item 3
- <system_message level="2" type="WARNING">
- <paragraph>
- Bullet list ends without a blank line; unexpected unindent at line 8.
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- item 4
-"""],
-["""\
-- item
-no blank line
-""",
-"""\
-<document>
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- item
- <system_message level="2" type="WARNING">
- <paragraph>
- Bullet list ends without a blank line; unexpected unindent at line 2.
- <paragraph>
- no blank line
-"""],
-["""\
--
-
-empty item above
-""",
-"""\
-<document>
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- empty item above
-"""],
-["""\
--
-empty item above, no blank line
-""",
-"""\
-<document>
- <bullet_list bullet="-">
- <list_item>
- <system_message level="2" type="WARNING">
- <paragraph>
- Bullet list ends without a blank line; unexpected unindent at line 2.
- <paragraph>
- empty item above, no blank line
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_citations.py b/docutils/test/test_parsers/test_rst/test_citations.py
deleted file mode 100755
index 803b1f2c3..000000000
--- a/docutils/test/test_parsers/test_rst/test_citations.py
+++ /dev/null
@@ -1,139 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['citations'] = [
-["""\
-.. [citation] This is a citation.
-""",
-"""\
-<document>
- <citation id="citation" name="citation">
- <label>
- citation
- <paragraph>
- This is a citation.
-"""],
-["""\
-.. [citation1234] This is a citation with year.
-""",
-"""\
-<document>
- <citation id="citation1234" name="citation1234">
- <label>
- citation1234
- <paragraph>
- This is a citation with year.
-"""],
-["""\
-.. [citation] This is a citation
- on multiple lines.
-""",
-"""\
-<document>
- <citation id="citation" name="citation">
- <label>
- citation
- <paragraph>
- This is a citation
- on multiple lines.
-"""],
-["""\
-.. [citation1] This is a citation
- on multiple lines with more space.
-
-.. [citation2] This is a citation
- on multiple lines with less space.
-""",
-"""\
-<document>
- <citation id="citation1" name="citation1">
- <label>
- citation1
- <paragraph>
- This is a citation
- on multiple lines with more space.
- <citation id="citation2" name="citation2">
- <label>
- citation2
- <paragraph>
- This is a citation
- on multiple lines with less space.
-"""],
-["""\
-.. [citation]
- This is a citation on multiple lines
- whose block starts on line 2.
-""",
-"""\
-<document>
- <citation id="citation" name="citation">
- <label>
- citation
- <paragraph>
- This is a citation on multiple lines
- whose block starts on line 2.
-"""],
-["""\
-.. [citation]
-
-That was an empty citation.
-""",
-"""\
-<document>
- <citation id="citation" name="citation">
- <label>
- citation
- <paragraph>
- That was an empty citation.
-"""],
-["""\
-.. [citation]
-No blank line.
-""",
-"""\
-<document>
- <citation id="citation" name="citation">
- <label>
- citation
- <system_message level="2" type="WARNING">
- <paragraph>
- Explicit markup ends without a blank line; unexpected unindent at line 2.
- <paragraph>
- No blank line.
-"""],
-["""\
-.. [citation label with spaces] this isn't a citation
-
-.. [*citationlabelwithmarkup*] this isn't a citation
-""",
-"""\
-<document>
- <comment>
- [citation label with spaces] this isn't a citation
- <comment>
- [*citationlabelwithmarkup*] this isn't a citation
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_comments.py b/docutils/test/test_parsers/test_rst/test_comments.py
deleted file mode 100755
index 11cea2a1e..000000000
--- a/docutils/test/test_parsers/test_rst/test_comments.py
+++ /dev/null
@@ -1,238 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['comments'] = [
-["""\
-.. A comment
-
-Paragraph.
-""",
-"""\
-<document>
- <comment>
- A comment
- <paragraph>
- Paragraph.
-"""],
-["""\
-.. A comment
- block.
-
-Paragraph.
-""",
-"""\
-<document>
- <comment>
- A comment
- block.
- <paragraph>
- Paragraph.
-"""],
-["""\
-..
- A comment consisting of multiple lines
- starting on the line after the
- explicit markup start.
-""",
-"""\
-<document>
- <comment>
- A comment consisting of multiple lines
- starting on the line after the
- explicit markup start.
-"""],
-["""\
-.. A comment.
-.. Another.
-
-Paragraph.
-""",
-"""\
-<document>
- <comment>
- A comment.
- <comment>
- Another.
- <paragraph>
- Paragraph.
-"""],
-["""\
-.. A comment
-no blank line
-
-Paragraph.
-""",
-"""\
-<document>
- <comment>
- A comment
- <system_message level="2" type="WARNING">
- <paragraph>
- Explicit markup ends without a blank line; unexpected unindent at line 2.
- <paragraph>
- no blank line
- <paragraph>
- Paragraph.
-"""],
-["""\
-.. A comment::
-
-Paragraph.
-""",
-"""\
-<document>
- <comment>
- A comment::
- <paragraph>
- Paragraph.
-"""],
-["""\
-.. Next is an empty comment, which serves to end this comment and
- prevents the following block quote being swallowed up.
-
-..
-
- A block quote.
-""",
-"""\
-<document>
- <comment>
- Next is an empty comment, which serves to end this comment and
- prevents the following block quote being swallowed up.
- <comment>
- <block_quote>
- <paragraph>
- A block quote.
-"""],
-["""\
-term 1
- definition 1
-
- .. a comment
-
-term 2
- definition 2
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- term 1
- <definition>
- <paragraph>
- definition 1
- <comment>
- a comment
- <definition_list_item>
- <term>
- term 2
- <definition>
- <paragraph>
- definition 2
-"""],
-["""\
-term 1
- definition 1
-
-.. a comment
-
-term 2
- definition 2
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- term 1
- <definition>
- <paragraph>
- definition 1
- <comment>
- a comment
- <definition_list>
- <definition_list_item>
- <term>
- term 2
- <definition>
- <paragraph>
- definition 2
-"""],
-["""\
-+ bullet paragraph 1
-
- bullet paragraph 2
-
- .. comment between bullet paragraphs 2 and 3
-
- bullet paragraph 3
-""",
-"""\
-<document>
- <bullet_list bullet="+">
- <list_item>
- <paragraph>
- bullet paragraph 1
- <paragraph>
- bullet paragraph 2
- <comment>
- comment between bullet paragraphs 2 and 3
- <paragraph>
- bullet paragraph 3
-"""],
-["""\
-+ bullet paragraph 1
-
- .. comment between bullet paragraphs 1 (leader) and 2
-
- bullet paragraph 2
-""",
-"""\
-<document>
- <bullet_list bullet="+">
- <list_item>
- <paragraph>
- bullet paragraph 1
- <comment>
- comment between bullet paragraphs 1 (leader) and 2
- <paragraph>
- bullet paragraph 2
-"""],
-["""\
-+ bullet
-
- .. trailing comment
-""",
-"""\
-<document>
- <bullet_list bullet="+">
- <list_item>
- <paragraph>
- bullet
- <comment>
- trailing comment
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_definition_lists.py b/docutils/test/test_parsers/test_rst/test_definition_lists.py
deleted file mode 100755
index c24e582ea..000000000
--- a/docutils/test/test_parsers/test_rst/test_definition_lists.py
+++ /dev/null
@@ -1,317 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['definition_lists'] = [
-["""\
-term
- definition
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- term
- <definition>
- <paragraph>
- definition
-"""],
-["""\
-term
- definition
-
-paragraph
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- term
- <definition>
- <paragraph>
- definition
- <paragraph>
- paragraph
-"""],
-["""\
-term
- definition
-no blank line
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- term
- <definition>
- <paragraph>
- definition
- <system_message level="2" type="WARNING">
- <paragraph>
- Definition list ends without a blank line; unexpected unindent at line 3.
- <paragraph>
- no blank line
-"""],
-["""\
-A paragraph::
- A literal block without a blank line first?
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- A paragraph::
- <definition>
- <system_message level="1" type="INFO">
- <paragraph>
- Blank line missing before literal block? Interpreted as a definition list item. At line 2.
- <paragraph>
- A literal block without a blank line first?
-"""],
-["""\
-term 1
- definition 1
-
-term 2
- definition 2
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- term 1
- <definition>
- <paragraph>
- definition 1
- <definition_list_item>
- <term>
- term 2
- <definition>
- <paragraph>
- definition 2
-"""],
-["""\
-term 1
- definition 1 (no blank line below)
-term 2
- definition 2
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- term 1
- <definition>
- <paragraph>
- definition 1 (no blank line below)
- <definition_list_item>
- <term>
- term 2
- <definition>
- <paragraph>
- definition 2
-"""],
-["""\
-term 1
- definition 1
-
- term 1a
- definition 1a
-
- term 1b
- definition 1b
-
-term 2
- definition 2
-
-paragraph
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- term 1
- <definition>
- <paragraph>
- definition 1
- <definition_list>
- <definition_list_item>
- <term>
- term 1a
- <definition>
- <paragraph>
- definition 1a
- <definition_list_item>
- <term>
- term 1b
- <definition>
- <paragraph>
- definition 1b
- <definition_list_item>
- <term>
- term 2
- <definition>
- <paragraph>
- definition 2
- <paragraph>
- paragraph
-"""],
-["""\
-Term : classifier
- The ' : ' indicates a classifier in
- definition list item terms only.
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- Term
- <classifier>
- classifier
- <definition>
- <paragraph>
- The ' : ' indicates a classifier in
- definition list item terms only.
-"""],
-["""\
-Term: not a classifier
- Because there's no space before the colon.
-Term :not a classifier
- Because there's no space after the colon.
-Term \: not a classifier
- Because the colon is escaped.
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- Term: not a classifier
- <definition>
- <paragraph>
- Because there's no space before the colon.
- <definition_list_item>
- <term>
- Term :not a classifier
- <definition>
- <paragraph>
- Because there's no space after the colon.
- <definition_list_item>
- <term>
- Term : not a classifier
- <definition>
- <paragraph>
- Because the colon is escaped.
-"""],
-["""\
-Term `with *inline ``text **errors : classifier `with *errors ``too
- Definition `with *inline ``text **markup errors.
-""",
-"""\
-<document>
- <definition_list>
- <definition_list_item>
- <term>
- Term \n\
- <problematic id="id2" refid="id1">
- `
- with \n\
- <problematic id="id4" refid="id3">
- *
- inline \n\
- <problematic id="id6" refid="id5">
- ``
- text \n\
- <problematic id="id8" refid="id7">
- **
- errors
- <classifier>
- classifier \n\
- <problematic id="id10" refid="id9">
- `
- with \n\
- <problematic id="id12" refid="id11">
- *
- errors \n\
- <problematic id="id14" refid="id13">
- ``
- too
- <definition>
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline interpreted text or phrase reference start-string without end-string at line 1.
- <system_message backrefs="id4" id="id3" level="2" type="WARNING">
- <paragraph>
- Inline emphasis start-string without end-string at line 1.
- <system_message backrefs="id6" id="id5" level="2" type="WARNING">
- <paragraph>
- Inline literal start-string without end-string at line 1.
- <system_message backrefs="id8" id="id7" level="2" type="WARNING">
- <paragraph>
- Inline strong start-string without end-string at line 1.
- <system_message backrefs="id10" id="id9" level="2" type="WARNING">
- <paragraph>
- Inline interpreted text or phrase reference start-string without end-string at line 1.
- <system_message backrefs="id12" id="id11" level="2" type="WARNING">
- <paragraph>
- Inline emphasis start-string without end-string at line 1.
- <system_message backrefs="id14" id="id13" level="2" type="WARNING">
- <paragraph>
- Inline literal start-string without end-string at line 1.
- <paragraph>
- Definition \n\
- <problematic id="id16" refid="id15">
- `
- with \n\
- <problematic id="id18" refid="id17">
- *
- inline \n\
- <problematic id="id20" refid="id19">
- ``
- text \n\
- <problematic id="id22" refid="id21">
- **
- markup errors.
- <system_message backrefs="id16" id="id15" level="2" type="WARNING">
- <paragraph>
- Inline interpreted text or phrase reference start-string without end-string at line 2.
- <system_message backrefs="id18" id="id17" level="2" type="WARNING">
- <paragraph>
- Inline emphasis start-string without end-string at line 2.
- <system_message backrefs="id20" id="id19" level="2" type="WARNING">
- <paragraph>
- Inline literal start-string without end-string at line 2.
- <system_message backrefs="id22" id="id21" level="2" type="WARNING">
- <paragraph>
- Inline strong start-string without end-string at line 2.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_directives/__init__.py b/docutils/test/test_parsers/test_rst/test_directives/__init__.py
deleted file mode 100644
index 8df5d4778..000000000
--- a/docutils/test/test_parsers/test_rst/test_directives/__init__.py
+++ /dev/null
@@ -1,12 +0,0 @@
-import os, os.path, 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_parsers/test_rst/test_directives/test_admonitions.py b/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py
deleted file mode 100755
index 87f82d527..000000000
--- a/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py
+++ /dev/null
@@ -1,117 +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 admonitions.py directives.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['admonitions'] = [
-["""\
-.. Attention:: Directives at large.
-
-.. Note:: This is a note.
-
-.. Tip:: 15% if the
- service is good.
-
-.. Hint:: It's bigger than a bread box.
-
-- .. WARNING:: Strong prose may provoke extreme mental exertion.
- Reader discretion is strongly advised.
-- .. Error:: Does not compute.
-
-.. Caution::
-
- Don't take any wooden nickels.
-
-.. DANGER:: Mad scientist at work!
-
-.. Important::
- - Wash behind your ears.
- - Clean up your room.
- - Call your mother.
- - Back up your data.
-""",
-"""\
-<document>
- <attention>
- <paragraph>
- Directives at large.
- <note>
- <paragraph>
- This is a note.
- <tip>
- <paragraph>
- 15% if the
- service is good.
- <hint>
- <paragraph>
- It's bigger than a bread box.
- <bullet_list bullet="-">
- <list_item>
- <warning>
- <paragraph>
- Strong prose may provoke extreme mental exertion.
- Reader discretion is strongly advised.
- <list_item>
- <error>
- <paragraph>
- Does not compute.
- <caution>
- <paragraph>
- Don't take any wooden nickels.
- <danger>
- <paragraph>
- Mad scientist at work!
- <important>
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- Wash behind your ears.
- <list_item>
- <paragraph>
- Clean up your room.
- <list_item>
- <paragraph>
- Call your mother.
- <list_item>
- <paragraph>
- Back up your data.
-"""],
-["""\
-.. note:: One-line notes.
-.. note:: One after the other.
-.. note:: No blank lines in-between.
-""",
-"""\
-<document>
- <note>
- <paragraph>
- One-line notes.
- <note>
- <paragraph>
- One after the other.
- <note>
- <paragraph>
- No blank lines in-between.
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_contents.py b/docutils/test/test_parsers/test_rst/test_directives/test_contents.py
deleted file mode 100755
index 4743798dc..000000000
--- a/docutils/test/test_parsers/test_rst/test_directives/test_contents.py
+++ /dev/null
@@ -1,166 +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 components.py contents directives.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['contents'] = [
-["""\
-.. contents::
-""",
-"""\
-<document>
- <pending>
- .. internal attributes:
- .transform: docutils.transforms.components.Contents
- .stage: 'last_reader'
- .details:
- title: None
-"""],
-["""\
-.. contents:: Table of Contents
-""",
-"""\
-<document>
- <pending>
- .. internal attributes:
- .transform: docutils.transforms.components.Contents
- .stage: 'last_reader'
- .details:
- title:
- <title>
- Table of Contents
-"""],
-["""\
-.. contents::
- Table of Contents
-""",
-"""\
-<document>
- <pending>
- .. internal attributes:
- .transform: docutils.transforms.components.Contents
- .stage: 'last_reader'
- .details:
- title:
- <title>
- Table of Contents
-"""],
-["""\
-.. contents:: Table
- of
- Contents
-""",
-"""\
-<document>
- <pending>
- .. internal attributes:
- .transform: docutils.transforms.components.Contents
- .stage: 'last_reader'
- .details:
- title:
- <title>
- Table of Contents
-"""],
-["""\
-.. contents:: *Table* of ``Contents``
-""",
-"""\
-<document>
- <pending>
- .. internal attributes:
- .transform: docutils.transforms.components.Contents
- .stage: 'last_reader'
- .details:
- title:
- <title>
- <emphasis>
- Table
- of
- <literal>
- Contents
-"""],
-["""\
-.. contents::
- :depth: 2
- :local:
-""",
-"""\
-<document>
- <pending>
- .. internal attributes:
- .transform: docutils.transforms.components.Contents
- .stage: 'last_reader'
- .details:
- depth: 2
- local: None
- title: None
-"""],
-["""\
-.. contents:: Table of Contents
- :local:
- :depth: 2
-""",
-"""\
-<document>
- <pending>
- .. internal attributes:
- .transform: docutils.transforms.components.Contents
- .stage: 'last_reader'
- .details:
- depth: 2
- local: None
- title:
- <title>
- Table of Contents
-"""],
-["""\
-.. contents::
- :depth: two
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error in "contents" directive attributes at line 1:
- invalid attribute value:
- (attribute "depth", value "'two'") invalid literal for int(): two.
- <literal_block>
- .. contents::
- :depth: two
-"""],
-["""\
-.. contents::
- :width: 2
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error in "contents" directive attributes at line 1:
- unknown attribute: "width".
- <literal_block>
- .. contents::
- :width: 2
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_figures.py b/docutils/test/test_parsers/test_rst/test_directives/test_figures.py
deleted file mode 100755
index 9e488ceca..000000000
--- a/docutils/test/test_parsers/test_rst/test_directives/test_figures.py
+++ /dev/null
@@ -1,286 +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 images.py figure directives.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['figures'] = [
-["""\
-.. figure:: picture.png
-""",
-"""\
-<document>
- <figure>
- <image uri="picture.png">
-"""],
-["""\
-.. figure:: not an image URI
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Image URI at line 1 contains whitespace.
- <literal_block>
- .. figure:: not an image URI
-"""],
-["""\
-.. figure:: picture.png
-
- A picture with a caption.
-""",
-"""\
-<document>
- <figure>
- <image uri="picture.png">
- <caption>
- A picture with a caption.
-"""],
-["""\
-.. figure:: picture.png
-
- - A picture with an invalid caption.
-""",
-"""\
-<document>
- <figure>
- <image uri="picture.png">
- <system_message level="3" type="ERROR">
- <paragraph>
- Figure caption must be a paragraph or empty comment.
- <literal_block>
- .. figure:: picture.png
- \n\
- - A picture with an invalid caption.
-"""],
-["""\
-.. figure:: not an image URI
-
- And a caption.
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Image URI at line 1 contains whitespace.
- <literal_block>
- .. figure:: not an image URI
-
- And a caption.
-"""],
-["""\
-.. figure:: picture.png
-
- ..
-
- A picture with a legend but no caption.
-""",
-"""\
-<document>
- <figure>
- <image uri="picture.png">
- <legend>
- <paragraph>
- A picture with a legend but no caption.
-"""],
-["""\
-.. Figure:: picture.png
- :height: 100
- :width: 200
- :scale: 50
-
- A picture with image attributes and a caption.
-""",
-"""\
-<document>
- <figure>
- <image height="100" scale="50" uri="picture.png" width="200">
- <caption>
- A picture with image attributes and a caption.
-"""],
-["""\
-.. Figure:: picture.png
- :height: 100
- :alt: alternate text
- :width: 200
- :scale: 50
-
- A picture with image attributes on individual lines, and this caption.
-""",
-"""\
-<document>
- <figure>
- <image alt="alternate text" height="100" scale="50" uri="picture.png" width="200">
- <caption>
- A picture with image attributes on individual lines, and this caption.
-"""],
-["""\
-This figure lacks a caption. It may still have a
-"Figure 1."-style caption appended in the output.
-
-.. figure:: picture.png
-""",
-"""\
-<document>
- <paragraph>
- This figure lacks a caption. It may still have a
- "Figure 1."-style caption appended in the output.
- <figure>
- <image uri="picture.png">
-"""],
-["""\
-.. figure:: picture.png
-
- A picture with a caption and a legend.
-
- +-----------------------+-----------------------+
- | Symbol | Meaning |
- +=======================+=======================+
- | .. image:: tent.png | Campground |
- +-----------------------+-----------------------+
- | .. image:: waves.png | Lake |
- +-----------------------+-----------------------+
- | .. image:: peak.png | Mountain |
- +-----------------------+-----------------------+
-""",
-"""\
-<document>
- <figure>
- <image uri="picture.png">
- <caption>
- A picture with a caption and a legend.
- <legend>
- <table>
- <tgroup cols="2">
- <colspec colwidth="23">
- <colspec colwidth="23">
- <thead>
- <row>
- <entry>
- <paragraph>
- Symbol
- <entry>
- <paragraph>
- Meaning
- <tbody>
- <row>
- <entry>
- <image uri="tent.png">
- <entry>
- <paragraph>
- Campground
- <row>
- <entry>
- <image uri="waves.png">
- <entry>
- <paragraph>
- Lake
- <row>
- <entry>
- <image uri="peak.png">
- <entry>
- <paragraph>
- Mountain
-"""],
-["""\
-.. figure:: picture.png
-
- ..
-
- A picture with a legend but no caption.
- (The empty comment replaces the caption, which must
- be a single paragraph.)
-""",
-"""\
-<document>
- <figure>
- <image uri="picture.png">
- <legend>
- <paragraph>
- A picture with a legend but no caption.
- (The empty comment replaces the caption, which must
- be a single paragraph.)
-"""],
-["""\
-Testing for line-leaks:
-
-.. figure:: picture.png
-
- A picture with a caption.
-.. figure:: picture.png
-
- A picture with a caption.
-.. figure:: picture.png
-
- A picture with a caption.
-.. figure:: picture.png
-.. figure:: picture.png
-.. figure:: picture.png
-.. figure:: picture.png
-
- A picture with a caption.
-
-.. figure:: picture.png
-
-.. figure:: picture.png
-
- A picture with a caption.
-
-.. figure:: picture.png
-""",
-"""\
-<document>
- <paragraph>
- Testing for line-leaks:
- <figure>
- <image uri="picture.png">
- <caption>
- A picture with a caption.
- <figure>
- <image uri="picture.png">
- <caption>
- A picture with a caption.
- <figure>
- <image uri="picture.png">
- <caption>
- A picture with a caption.
- <figure>
- <image uri="picture.png">
- <figure>
- <image uri="picture.png">
- <figure>
- <image uri="picture.png">
- <figure>
- <image uri="picture.png">
- <caption>
- A picture with a caption.
- <figure>
- <image uri="picture.png">
- <figure>
- <image uri="picture.png">
- <caption>
- A picture with a caption.
- <figure>
- <image uri="picture.png">
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_images.py b/docutils/test/test_parsers/test_rst/test_directives/test_images.py
deleted file mode 100755
index e49a2c3aa..000000000
--- a/docutils/test/test_parsers/test_rst/test_directives/test_images.py
+++ /dev/null
@@ -1,233 +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 images.py image directives.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['images'] = [
-["""\
-.. image:: picture.png
-""",
-"""\
-<document>
- <image uri="picture.png">
-"""],
-["""\
-.. image::
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Missing image URI argument at line 1.
- <literal_block>
- .. image::
-"""],
-["""\
-.. image:: one two three
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Image URI at line 1 contains whitespace.
- <literal_block>
- .. image:: one two three
-"""],
-["""\
-.. image:: picture.png
- :height: 100
- :width: 200
- :scale: 50
-""",
-"""\
-<document>
- <image height="100" scale="50" uri="picture.png" width="200">
-"""],
-["""\
-.. image::
- picture.png
- :height: 100
- :width: 200
- :scale: 50
-""",
-"""\
-<document>
- <image height="100" scale="50" uri="picture.png" width="200">
-"""],
-["""\
-.. image::
- :height: 100
- :width: 200
- :scale: 50
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Missing image URI argument at line 1.
- <literal_block>
- .. image::
- :height: 100
- :width: 200
- :scale: 50
-"""],
-["""\
-.. image:: a/very/long/path/to/
- picture.png
- :height: 100
- :width: 200
- :scale: 50
-""",
-"""\
-<document>
- <image height="100" scale="50" uri="a/very/long/path/to/picture.png" width="200">
-"""],
-["""\
-.. image:: picture.png
- :height: 100
- :width: 200
- :scale: 50
- :alt: Alternate text for the picture
-""",
-"""\
-<document>
- <image alt="Alternate text for the picture" height="100" scale="50" uri="picture.png" width="200">
-"""],
-["""\
-.. image:: picture.png
- :scale: - 50
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error in "image" directive attributes at line 1:
- invalid attribute data: extension attribute field body may contain
- a single paragraph only (attribute "scale").
- <literal_block>
- .. image:: picture.png
- :scale: - 50
-"""],
-["""\
-.. image:: picture.png
- :scale:
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error in "image" directive attributes at line 1:
- invalid attribute value:
- (attribute "scale", value "None") object can't be converted to int.
- <literal_block>
- .. image:: picture.png
- :scale:
-"""],
-["""\
-.. image:: picture.png
- :scale 50
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error in "image" directive attributes at line 1:
- invalid attribute block.
- <literal_block>
- .. image:: picture.png
- :scale 50
-"""],
-["""\
-.. image:: picture.png
- scale: 50
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Image URI at line 1 contains whitespace.
- <literal_block>
- .. image:: picture.png
- scale: 50
-"""],
-["""\
-.. image:: picture.png
- :: 50
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error in "image" directive attributes at line 1:
- invalid attribute block.
- <literal_block>
- .. image:: picture.png
- :: 50
-"""],
-["""\
-.. image:: picture.png
- :sale: 50
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error in "image" directive attributes at line 1:
- unknown attribute: "sale".
- <literal_block>
- .. image:: picture.png
- :sale: 50
-"""],
-["""\
-.. image:: picture.png
- :scale: fifty
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error in "image" directive attributes at line 1:
- invalid attribute value:
- (attribute "scale", value "'fifty'") invalid literal for int(): fifty.
- <literal_block>
- .. image:: picture.png
- :scale: fifty
-"""],
-["""\
-.. image:: picture.png
- :scale: 50
- :scale: 50
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error in "image" directive attributes at line 1:
- invalid attribute data: duplicate attribute "scale".
- <literal_block>
- .. image:: picture.png
- :scale: 50
- :scale: 50
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_meta.py b/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
deleted file mode 100755
index 8cdc93bd6..000000000
--- a/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
+++ /dev/null
@@ -1,141 +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 html.py meta directives.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['meta'] = [
-["""\
-.. meta::
- :description: The reStructuredText plaintext markup language
- :keywords: plaintext,markup language
-""",
-"""\
-<document>
- <meta content="The reStructuredText plaintext markup language" name="description">
- <meta content="plaintext,markup language" name="keywords">
-"""],
-["""\
-.. meta::
- :description lang=en: An amusing story
- :description lang=fr: Un histoire amusant
-""",
-"""\
-<document>
- <meta content="An amusing story" lang="en" name="description">
- <meta content="Un histoire amusant" lang="fr" name="description">
-"""],
-["""\
-.. meta::
- :http-equiv=Content-Type: text/html; charset=ISO-8859-1
-""",
-"""\
-<document>
- <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
-"""],
-["""\
-.. meta::
- :name: content
- over multiple lines
-""",
-"""\
-<document>
- <meta content="content over multiple lines" name="name">
-"""],
-["""\
-Paragraph
-
-.. meta::
- :name: content
-""",
-"""\
-<document>
- <paragraph>
- Paragraph
- <meta content="content" name="name">
-"""],
-["""\
-.. meta::
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Empty meta directive at line 1.
-"""],
-["""\
-.. meta::
- :empty:
-""",
-"""\
-<document>
- <system_message level="1" type="INFO">
- <paragraph>
- No content for meta tag "empty".
- <literal_block>
- :empty:
- <meta content="" name="empty">
-"""],
-["""\
-.. meta::
- not a field list
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Invalid meta directive at line 2.
- <literal_block>
- .. meta::
- not a field list
-"""],
-["""\
-.. meta::
- :name: content
- not a field
-""",
-"""\
-<document>
- <meta content="content" name="name">
- <system_message level="3" type="ERROR">
- <paragraph>
- Invalid meta directive at line 3.
- <literal_block>
- .. meta::
- :name: content
- not a field
-"""],
-["""\
-.. meta::
- :name notattval: content
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Error parsing meta tag attribute "notattval": missing "="
- <literal_block>
- :name notattval: content
- <meta content="content" name="name">
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_test_directives.py b/docutils/test/test_parsers/test_rst/test_directives/test_test_directives.py
deleted file mode 100755
index 4c7feb970..000000000
--- a/docutils/test/test_parsers/test_rst/test_directives/test_test_directives.py
+++ /dev/null
@@ -1,109 +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 misc.py test directives.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['test_directives'] = [
-["""\
-.. reStructuredText-test-directive::
-
-Paragraph.
-""",
-"""\
-<document>
- <system_message level="1" type="INFO">
- <paragraph>
- Directive processed. Type="reStructuredText-test-directive", data="", directive block: None
- <paragraph>
- Paragraph.
-"""],
-["""\
-.. reStructuredText-test-directive:: argument
-
-Paragraph.
-""",
-"""\
-<document>
- <system_message level="1" type="INFO">
- <paragraph>
- Directive processed. Type="reStructuredText-test-directive", data="argument", directive block: None
- <paragraph>
- Paragraph.
-"""],
-["""\
-.. reStructuredText-test-directive::
-
- Directive block contains one paragraph, with a blank line before.
-
-Paragraph.
-""",
-"""\
-<document>
- <system_message level="1" type="INFO">
- <paragraph>
- Directive processed. Type="reStructuredText-test-directive", data="", directive block:
- <literal_block>
- Directive block contains one paragraph, with a blank line before.
- <paragraph>
- Paragraph.
-"""],
-["""\
-.. reStructuredText-test-directive::
- Directive block contains one paragraph, no blank line before.
-
-Paragraph.
-""",
-"""\
-<document>
- <system_message level="1" type="INFO">
- <paragraph>
- Directive processed. Type="reStructuredText-test-directive", data="", directive block:
- <literal_block>
- Directive block contains one paragraph, no blank line before.
- <paragraph>
- Paragraph.
-"""],
-["""\
-.. reStructuredText-test-directive::
- block
-no blank line.
-
-Paragraph.
-""",
-"""\
-<document>
- <system_message level="1" type="INFO">
- <paragraph>
- Directive processed. Type="reStructuredText-test-directive", data="", directive block:
- <literal_block>
- block
- <system_message level="2" type="WARNING">
- <paragraph>
- Explicit markup ends without a blank line; unexpected unindent at line 3.
- <paragraph>
- no blank line.
- <paragraph>
- Paragraph.
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_unknown.py b/docutils/test/test_parsers/test_rst/test_directives/test_unknown.py
deleted file mode 100755
index 46af7dcfd..000000000
--- a/docutils/test/test_parsers/test_rst/test_directives/test_unknown.py
+++ /dev/null
@@ -1,55 +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 unknown directives.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['unknown'] = [
-["""\
-.. reStructuredText-unknown-directive::
-
-.. reStructuredText-unknown-directive:: argument
-
-.. reStructuredText-unknown-directive::
- block
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Unknown directive type "reStructuredText-unknown-directive" at line 1.
- <literal_block>
- .. reStructuredText-unknown-directive::
- <system_message level="3" type="ERROR">
- <paragraph>
- Unknown directive type "reStructuredText-unknown-directive" at line 3.
- <literal_block>
- .. reStructuredText-unknown-directive:: argument
- <system_message level="3" type="ERROR">
- <paragraph>
- Unknown directive type "reStructuredText-unknown-directive" at line 5.
- <literal_block>
- .. reStructuredText-unknown-directive::
- block
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_doctest_blocks.py b/docutils/test/test_parsers/test_rst/test_doctest_blocks.py
deleted file mode 100755
index 70f182fd0..000000000
--- a/docutils/test/test_parsers/test_rst/test_doctest_blocks.py
+++ /dev/null
@@ -1,74 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['doctest_blocks'] = [
-["""\
-Paragraph.
-
->>> print "Doctest block."
-Doctest block.
-
-Paragraph.
-""",
-"""\
-<document>
- <paragraph>
- Paragraph.
- <doctest_block>
- >>> print "Doctest block."
- Doctest block.
- <paragraph>
- Paragraph.
-"""],
-["""\
-Paragraph.
-
->>> print " Indented output."
- Indented output.
-""",
-"""\
-<document>
- <paragraph>
- Paragraph.
- <doctest_block>
- >>> print " Indented output."
- Indented output.
-"""],
-["""\
-Paragraph.
-
- >>> print " Indented block & output."
- Indented block & output.
-""",
-"""\
-<document>
- <paragraph>
- Paragraph.
- <block_quote>
- <doctest_block>
- >>> print " Indented block & output."
- Indented block & output.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_enumerated_lists.py b/docutils/test/test_parsers/test_rst/test_enumerated_lists.py
deleted file mode 100755
index 0eb599e44..000000000
--- a/docutils/test/test_parsers/test_rst/test_enumerated_lists.py
+++ /dev/null
@@ -1,662 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['enumerated_lists'] = [
-["""\
-1. Item one.
-
-2. Item two.
-
-3. Item three.
-""",
-"""\
-<document>
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item one.
- <list_item>
- <paragraph>
- Item two.
- <list_item>
- <paragraph>
- Item three.
-"""],
-["""\
-No blank lines betwen items:
-
-1. Item one.
-2. Item two.
-3. Item three.
-""",
-"""\
-<document>
- <paragraph>
- No blank lines betwen items:
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item one.
- <list_item>
- <paragraph>
- Item two.
- <list_item>
- <paragraph>
- Item three.
-"""],
-["""\
-1.
-empty item above, no blank line
-""",
-"""\
-<document>
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
- <list_item>
- <system_message level="2" type="WARNING">
- <paragraph>
- Enumerated list ends without a blank line; unexpected unindent at line 2.
- <paragraph>
- empty item above, no blank line
-"""],
-["""\
-Scrambled:
-
-3. Item three.
-2. Item two.
-1. Item one.
-""",
-"""\
-<document>
- <paragraph>
- Scrambled:
- <system_message level="1" type="INFO">
- <paragraph>
- Enumerated list start value not ordinal-1 at line 3: '3' (ordinal 3)
- <enumerated_list enumtype="arabic" prefix="" start="3" suffix=".">
- <list_item>
- <paragraph>
- Item three.
- <system_message level="2" type="WARNING">
- <paragraph>
- Enumerated list ends without a blank line; unexpected unindent at line 4.
- <system_message level="1" type="INFO">
- <paragraph>
- Enumerated list start value not ordinal-1 at line 4: '2' (ordinal 2)
- <enumerated_list enumtype="arabic" prefix="" start="2" suffix=".">
- <list_item>
- <paragraph>
- Item two.
- <system_message level="2" type="WARNING">
- <paragraph>
- Enumerated list ends without a blank line; unexpected unindent at line 5.
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item one.
-"""],
-["""\
-Skipping item 3:
-
-1. Item 1.
-2. Item 2.
-4. Item 4.
-""",
-"""\
-<document>
- <paragraph>
- Skipping item 3:
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item 1.
- <list_item>
- <paragraph>
- Item 2.
- <system_message level="2" type="WARNING">
- <paragraph>
- Enumerated list ends without a blank line; unexpected unindent at line 4.
- <system_message level="1" type="INFO">
- <paragraph>
- Enumerated list start value not ordinal-1 at line 5: '4' (ordinal 4)
- <enumerated_list enumtype="arabic" prefix="" start="4" suffix=".">
- <list_item>
- <paragraph>
- Item 4.
-"""],
-["""\
-Start with non-ordinal-1:
-
-0. Item zero.
-1. Item one.
-2. Item two.
-3. Item three.
-
-And again:
-
-2. Item two.
-3. Item three.
-""",
-"""\
-<document>
- <paragraph>
- Start with non-ordinal-1:
- <system_message level="1" type="INFO">
- <paragraph>
- Enumerated list start value not ordinal-1 at line 3: '0' (ordinal 0)
- <enumerated_list enumtype="arabic" prefix="" start="0" suffix=".">
- <list_item>
- <paragraph>
- Item zero.
- <list_item>
- <paragraph>
- Item one.
- <list_item>
- <paragraph>
- Item two.
- <list_item>
- <paragraph>
- Item three.
- <paragraph>
- And again:
- <system_message level="1" type="INFO">
- <paragraph>
- Enumerated list start value not ordinal-1 at line 10: '2' (ordinal 2)
- <enumerated_list enumtype="arabic" prefix="" start="2" suffix=".">
- <list_item>
- <paragraph>
- Item two.
- <list_item>
- <paragraph>
- Item three.
-"""],
-["""\
-1. Item one: line 1,
- line 2.
-2. Item two: line 1,
- line 2.
-3. Item three: paragraph 1, line 1,
- line 2.
-
- Paragraph 2.
-""",
-"""\
-<document>
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item one: line 1,
- line 2.
- <list_item>
- <paragraph>
- Item two: line 1,
- line 2.
- <list_item>
- <paragraph>
- Item three: paragraph 1, line 1,
- line 2.
- <paragraph>
- Paragraph 2.
-"""],
-["""\
-Different enumeration sequences:
-
-1. Item 1.
-2. Item 2.
-3. Item 3.
-
-A. Item A.
-B. Item B.
-C. Item C.
-
-a. Item a.
-b. Item b.
-c. Item c.
-
-I. Item I.
-II. Item II.
-III. Item III.
-
-i. Item i.
-ii. Item ii.
-iii. Item iii.
-""",
-"""\
-<document>
- <paragraph>
- Different enumeration sequences:
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item 1.
- <list_item>
- <paragraph>
- Item 2.
- <list_item>
- <paragraph>
- Item 3.
- <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item A.
- <list_item>
- <paragraph>
- Item B.
- <list_item>
- <paragraph>
- Item C.
- <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item a.
- <list_item>
- <paragraph>
- Item b.
- <list_item>
- <paragraph>
- Item c.
- <enumerated_list enumtype="upperroman" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item I.
- <list_item>
- <paragraph>
- Item II.
- <list_item>
- <paragraph>
- Item III.
- <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item i.
- <list_item>
- <paragraph>
- Item ii.
- <list_item>
- <paragraph>
- Item iii.
-"""],
-["""\
-Bad Roman numerals:
-
-i. i
-ii. ii
-iii. iii
-iiii. iiii
-
-(I) I
-(IVXLCDM) IVXLCDM
-""",
-"""\
-<document>
- <paragraph>
- Bad Roman numerals:
- <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
- <list_item>
- <paragraph>
- i
- <list_item>
- <paragraph>
- ii
- <list_item>
- <paragraph>
- iii
- <system_message level="2" type="WARNING">
- <paragraph>
- Enumerated list ends without a blank line; unexpected unindent at line 4.
- <system_message level="3" type="ERROR">
- <paragraph>
- Enumerated list start value invalid at line 6: 'iiii' (sequence 'lowerroman')
- <block_quote>
- <paragraph>
- iiii
- <enumerated_list enumtype="upperroman" prefix="(" suffix=")">
- <list_item>
- <paragraph>
- I
- <system_message level="2" type="WARNING">
- <paragraph>
- Enumerated list ends without a blank line; unexpected unindent at line 9.
- <system_message level="3" type="ERROR">
- <paragraph>
- Enumerated list start value invalid at line 9: 'IVXLCDM' (sequence 'upperroman')
- <block_quote>
- <paragraph>
- IVXLCDM
-"""],
-["""\
-Potentially ambiguous cases:
-
-A. Item A.
-B. Item B.
-C. Item C.
-
-I. Item I.
-II. Item II.
-III. Item III.
-
-a. Item a.
-b. Item b.
-c. Item c.
-
-i. Item i.
-ii. Item ii.
-iii. Item iii.
-
-Phew! Safe!
-""",
-"""\
-<document>
- <paragraph>
- Potentially ambiguous cases:
- <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item A.
- <list_item>
- <paragraph>
- Item B.
- <list_item>
- <paragraph>
- Item C.
- <enumerated_list enumtype="upperroman" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item I.
- <list_item>
- <paragraph>
- Item II.
- <list_item>
- <paragraph>
- Item III.
- <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item a.
- <list_item>
- <paragraph>
- Item b.
- <list_item>
- <paragraph>
- Item c.
- <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item i.
- <list_item>
- <paragraph>
- Item ii.
- <list_item>
- <paragraph>
- Item iii.
- <paragraph>
- Phew! Safe!
-"""],
-["""\
-Definitely ambiguous:
-
-A. Item A.
-B. Item B.
-C. Item C.
-D. Item D.
-E. Item E.
-F. Item F.
-G. Item G.
-H. Item H.
-I. Item I.
-II. Item II.
-III. Item III.
-
-a. Item a.
-b. Item b.
-c. Item c.
-d. Item d.
-e. Item e.
-f. Item f.
-g. Item g.
-h. Item h.
-i. Item i.
-ii. Item ii.
-iii. Item iii.
-""",
-"""\
-<document>
- <paragraph>
- Definitely ambiguous:
- <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item A.
- <list_item>
- <paragraph>
- Item B.
- <list_item>
- <paragraph>
- Item C.
- <list_item>
- <paragraph>
- Item D.
- <list_item>
- <paragraph>
- Item E.
- <list_item>
- <paragraph>
- Item F.
- <list_item>
- <paragraph>
- Item G.
- <list_item>
- <paragraph>
- Item H.
- <list_item>
- <paragraph>
- Item I.
- <system_message level="2" type="WARNING">
- <paragraph>
- Enumerated list ends without a blank line; unexpected unindent at line 4.
- <system_message level="1" type="INFO">
- <paragraph>
- Enumerated list start value not ordinal-1 at line 12: 'II' (ordinal 2)
- <enumerated_list enumtype="upperroman" prefix="" start="2" suffix=".">
- <list_item>
- <paragraph>
- Item II.
- <list_item>
- <paragraph>
- Item III.
- <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item a.
- <list_item>
- <paragraph>
- Item b.
- <list_item>
- <paragraph>
- Item c.
- <list_item>
- <paragraph>
- Item d.
- <list_item>
- <paragraph>
- Item e.
- <list_item>
- <paragraph>
- Item f.
- <list_item>
- <paragraph>
- Item g.
- <list_item>
- <paragraph>
- Item h.
- <list_item>
- <paragraph>
- Item i.
- <system_message level="2" type="WARNING">
- <paragraph>
- Enumerated list ends without a blank line; unexpected unindent at line 16.
- <system_message level="1" type="INFO">
- <paragraph>
- Enumerated list start value not ordinal-1 at line 24: 'ii' (ordinal 2)
- <enumerated_list enumtype="lowerroman" prefix="" start="2" suffix=".">
- <list_item>
- <paragraph>
- Item ii.
- <list_item>
- <paragraph>
- Item iii.
-"""],
-["""\
-Different enumeration formats:
-
-1. Item 1.
-2. Item 2.
-3. Item 3.
-
-1) Item 1).
-2) Item 2).
-3) Item 3).
-
-(1) Item (1).
-(2) Item (2).
-(3) Item (3).
-""",
-"""\
-<document>
- <paragraph>
- Different enumeration formats:
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item 1.
- <list_item>
- <paragraph>
- Item 2.
- <list_item>
- <paragraph>
- Item 3.
- <enumerated_list enumtype="arabic" prefix="" suffix=")">
- <list_item>
- <paragraph>
- Item 1).
- <list_item>
- <paragraph>
- Item 2).
- <list_item>
- <paragraph>
- Item 3).
- <enumerated_list enumtype="arabic" prefix="(" suffix=")">
- <list_item>
- <paragraph>
- Item (1).
- <list_item>
- <paragraph>
- Item (2).
- <list_item>
- <paragraph>
- Item (3).
-"""],
-["""\
-Nested enumerated lists:
-
-1. Item 1.
-
- A) Item A).
- B) Item B).
- C) Item C).
-
-2. Item 2.
-
- (a) Item (a).
-
- I) Item I).
- II) Item II).
- III) Item III).
-
- (b) Item (b).
-
- (c) Item (c).
-
- (i) Item (i).
- (ii) Item (ii).
- (iii) Item (iii).
-
-3. Item 3.
-""",
-"""\
-<document>
- <paragraph>
- Nested enumerated lists:
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
- <list_item>
- <paragraph>
- Item 1.
- <enumerated_list enumtype="upperalpha" prefix="" suffix=")">
- <list_item>
- <paragraph>
- Item A).
- <list_item>
- <paragraph>
- Item B).
- <list_item>
- <paragraph>
- Item C).
- <list_item>
- <paragraph>
- Item 2.
- <enumerated_list enumtype="loweralpha" prefix="(" suffix=")">
- <list_item>
- <paragraph>
- Item (a).
- <enumerated_list enumtype="upperroman" prefix="" suffix=")">
- <list_item>
- <paragraph>
- Item I).
- <list_item>
- <paragraph>
- Item II).
- <list_item>
- <paragraph>
- Item III).
- <list_item>
- <paragraph>
- Item (b).
- <list_item>
- <paragraph>
- Item (c).
- <enumerated_list enumtype="lowerroman" prefix="(" suffix=")">
- <list_item>
- <paragraph>
- Item (i).
- <list_item>
- <paragraph>
- Item (ii).
- <list_item>
- <paragraph>
- Item (iii).
- <list_item>
- <paragraph>
- Item 3.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_field_lists.py b/docutils/test/test_parsers/test_rst/test_field_lists.py
deleted file mode 100755
index 254126af4..000000000
--- a/docutils/test/test_parsers/test_rst/test_field_lists.py
+++ /dev/null
@@ -1,491 +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 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
-""",
-"""\
-<document>
- <paragraph>
- One-liners:
- <field_list>
- <field>
- <field_name>
- Author
- <field_body>
- <paragraph>
- Me
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2001-08-11
- <field>
- <field_name>
- Parameter
- <field_argument>
- i
- <field_body>
- <paragraph>
- integer
-"""],
-["""\
-One-liners, no blank lines:
-
-:Author: Me
-:Version: 1
-:Date: 2001-08-11
-:Parameter i: integer
-""",
-"""\
-<document>
- <paragraph>
- One-liners, no blank lines:
- <field_list>
- <field>
- <field_name>
- Author
- <field_body>
- <paragraph>
- Me
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2001-08-11
- <field>
- <field_name>
- Parameter
- <field_argument>
- i
- <field_body>
- <paragraph>
- integer
-"""],
-["""\
-:field:
-empty item above, no blank line
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- field
- <field_body>
- <system_message level="2" type="WARNING">
- <paragraph>
- Field list ends without a blank line; unexpected unindent at line 2.
- <paragraph>
- empty item above, no blank line
-"""],
-["""\
-Field bodies starting on the next line:
-
-:Author:
- Me
-:Version:
- 1
-:Date:
- 2001-08-11
-:Parameter i:
- integer
-""",
-"""\
-<document>
- <paragraph>
- Field bodies starting on the next line:
- <field_list>
- <field>
- <field_name>
- Author
- <field_body>
- <paragraph>
- Me
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2001-08-11
- <field>
- <field_name>
- Parameter
- <field_argument>
- i
- <field_body>
- <paragraph>
- integer
-"""],
-["""\
-One-paragraph, multi-liners:
-
-:Authors: Me,
- Myself,
- and I
-:Version: 1
- or so
-:Date: 2001-08-11
- (Saturday)
-:Parameter i: counter
- (integer)
-""",
-"""\
-<document>
- <paragraph>
- One-paragraph, multi-liners:
- <field_list>
- <field>
- <field_name>
- Authors
- <field_body>
- <paragraph>
- Me,
- Myself,
- and I
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- or so
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2001-08-11
- (Saturday)
- <field>
- <field_name>
- Parameter
- <field_argument>
- i
- <field_body>
- <paragraph>
- 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)
-""",
-"""\
-<document>
- <paragraph>
- One-paragraph, multi-liners, not lined up:
- <field_list>
- <field>
- <field_name>
- Authors
- <field_body>
- <paragraph>
- Me,
- Myself,
- and I
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- or so
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2001-08-11
- (Saturday)
- <field>
- <field_name>
- Parameter
- <field_argument>
- i
- <field_body>
- <paragraph>
- 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
-""",
-"""\
-<document>
- <paragraph>
- Multiple body elements:
- <field_list>
- <field>
- <field_name>
- Authors
- <field_body>
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- Me
- <list_item>
- <paragraph>
- Myself
- <list_item>
- <paragraph>
- I
- <field>
- <field_name>
- Abstract
- <field_body>
- <paragraph>
- This is a field list item's body,
- containing multiple elements.
- <paragraph>
- Here's a literal block:
- <literal_block>
- def f(x):
- return x**2 + x
- <paragraph>
- Even nested field lists are possible:
- <field_list>
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2001-08-11
- <field>
- <field_name>
- Day
- <field_body>
- <paragraph>
- Saturday
- <field>
- <field_name>
- Time
- <field_body>
- <paragraph>
- 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
-""",
-"""\
-<document>
- <paragraph>
- Nested field lists on one line:
- <field_list>
- <field>
- <field_name>
- field1
- <field_body>
- <field_list>
- <field>
- <field_name>
- field2
- <field_body>
- <field_list>
- <field>
- <field_name>
- field3
- <field_body>
- <paragraph>
- body
- <field>
- <field_name>
- field4
- <field_body>
- <field_list>
- <field>
- <field_name>
- field5
- <field_body>
- <field_list>
- <field>
- <field_name>
- field6
- <field_body>
- <paragraph>
- body
- <field>
- <field_name>
- field7
- <field_body>
- <paragraph>
- body
- <field>
- <field_name>
- field8
- <field_body>
- <paragraph>
- body
- <field>
- <field_name>
- field9
- <field_body>
- <paragraph>
- body line 1
- body line 2
-"""],
-["""\
-:Parameter i j k: multiple arguments
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- Parameter
- <field_argument>
- i
- <field_argument>
- j
- <field_argument>
- k
- <field_body>
- <paragraph>
- multiple arguments
-"""],
-["""\
-Some edge cases:
-
-:Empty:
-:Author: Me
-No blank line before this paragraph.
-
-:*Field* `with` **inline** ``markup``: inline markup shouldn't be recognized.
-
-: 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.
-""",
-"""\
-<document>
- <paragraph>
- Some edge cases:
- <field_list>
- <field>
- <field_name>
- Empty
- <field_body>
- <field>
- <field_name>
- Author
- <field_body>
- <paragraph>
- Me
- <system_message level="2" type="WARNING">
- <paragraph>
- Field list ends without a blank line; unexpected unindent at line 4.
- <paragraph>
- No blank line before this paragraph.
- <field_list>
- <field>
- <field_name>
- *Field*
- <field_argument>
- `with`
- <field_argument>
- **inline**
- <field_argument>
- ``markup``
- <field_body>
- <paragraph>
- inline markup shouldn't be recognized.
- <paragraph>
- : Field: marker must not begin with whitespace.
- <paragraph>
- :Field : marker must not end with whitespace.
- <paragraph>
- Field: marker is missing its open-colon.
- <paragraph>
- :Field marker is missing its close-colon.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_footnotes.py b/docutils/test/test_parsers/test_rst/test_footnotes.py
deleted file mode 100755
index 60511b1a6..000000000
--- a/docutils/test/test_parsers/test_rst/test_footnotes.py
+++ /dev/null
@@ -1,332 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['footnotes'] = [
-["""\
-.. [1] This is a footnote.
-""",
-"""\
-<document>
- <footnote id="id1" name="1">
- <label>
- 1
- <paragraph>
- This is a footnote.
-"""],
-["""\
-.. [1] This is a footnote
- on multiple lines.
-""",
-"""\
-<document>
- <footnote id="id1" name="1">
- <label>
- 1
- <paragraph>
- This is a footnote
- on multiple lines.
-"""],
-["""\
-.. [1] This is a footnote
- on multiple lines with more space.
-
-.. [2] This is a footnote
- on multiple lines with less space.
-""",
-"""\
-<document>
- <footnote id="id1" name="1">
- <label>
- 1
- <paragraph>
- This is a footnote
- on multiple lines with more space.
- <footnote id="id2" name="2">
- <label>
- 2
- <paragraph>
- This is a footnote
- on multiple lines with less space.
-"""],
-["""\
-.. [1]
- This is a footnote on multiple lines
- whose block starts on line 2.
-""",
-"""\
-<document>
- <footnote id="id1" name="1">
- <label>
- 1
- <paragraph>
- This is a footnote on multiple lines
- whose block starts on line 2.
-"""],
-["""\
-.. [1]
-
-That was an empty footnote.
-""",
-"""\
-<document>
- <footnote id="id1" name="1">
- <label>
- 1
- <paragraph>
- That was an empty footnote.
-"""],
-["""\
-.. [1]
-No blank line.
-""",
-"""\
-<document>
- <footnote id="id1" name="1">
- <label>
- 1
- <system_message level="2" type="WARNING">
- <paragraph>
- Explicit markup ends without a blank line; unexpected unindent at line 2.
- <paragraph>
- No blank line.
-"""],
-]
-
-totest['auto_numbered_footnotes'] = [
-["""\
-[#]_ 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>
- <paragraph>
- <footnote_reference auto="1" id="id1">
- is the first auto-numbered footnote reference.
- <footnote_reference auto="1" id="id2">
- is the second auto-numbered footnote reference.
- <footnote auto="1" id="id3">
- <paragraph>
- Auto-numbered footnote 1.
- <footnote auto="1" id="id4">
- <paragraph>
- Auto-numbered footnote 2.
- <footnote auto="1" id="id5">
- <paragraph>
- Auto-numbered footnote 3.
- <paragraph>
- <footnote_reference auto="1" id="id6">
- 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 targets generated by
-the footnotes: first_, second_, third_.
-""",
-"""\
-<document>
- <paragraph>
- <footnote_reference auto="1" id="id1" refname="third">
- is a reference to the third auto-numbered footnote.
- <footnote auto="1" id="first" name="first">
- <paragraph>
- First auto-numbered footnote.
- <footnote auto="1" id="second" name="second">
- <paragraph>
- Second auto-numbered footnote.
- <footnote auto="1" id="third" name="third">
- <paragraph>
- Third auto-numbered footnote.
- <paragraph>
- <footnote_reference auto="1" id="id2" refname="second">
- is a reference to the second auto-numbered footnote.
- <footnote_reference auto="1" id="id3" refname="first">
- is a reference to the first auto-numbered footnote.
- <footnote_reference auto="1" id="id4" refname="third">
- is another reference to the third auto-numbered footnote.
- <paragraph>
- Here are some internal cross-references to the 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>
- <paragraph>
- Mixed anonymous and labelled auto-numbered footnotes:
- <paragraph>
- <footnote_reference auto="1" id="id1" refname="four">
- should be 4, \n\
- <footnote_reference auto="1" id="id2">
- should be 1,
- <footnote_reference auto="1" id="id3">
- should be 3, \n\
- <footnote_reference auto="1" id="id4">
- is one too many,
- <footnote_reference auto="1" id="id5" refname="two">
- should be 2, and \n\
- <footnote_reference auto="1" id="id6" refname="six">
- doesn't exist.
- <footnote auto="1" id="id7">
- <paragraph>
- Auto-numbered footnote 1.
- <footnote auto="1" id="two" name="two">
- <paragraph>
- Auto-numbered footnote 2.
- <footnote auto="1" id="id8">
- <paragraph>
- Auto-numbered footnote 3.
- <footnote auto="1" id="four" name="four">
- <paragraph>
- Auto-numbered footnote 4.
- <footnote auto="1" dupname="five" id="five">
- <paragraph>
- Auto-numbered footnote 5.
- <footnote auto="1" dupname="five" id="id9">
- <system_message backrefs="id9" level="2" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "five".
- <paragraph>
- Auto-numbered footnote 5 again (duplicate).
-"""],
-["""\
-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 [#six]_ 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.
-.. [#five] Auto-numbered footnote 5 again (duplicate).
-.. [#] Auto-numbered footnote 6.
-""",
-"""\
-<document>
- <paragraph>
- Mixed manually-numbered, anonymous auto-numbered,
- and labelled auto-numbered footnotes:
- <paragraph>
- <footnote_reference auto="1" id="id1" refname="four">
- should be 4, \n\
- <footnote_reference auto="1" id="id2">
- should be 2,
- <footnote_reference id="id3" refname="1">
- 1
- is 1, \n\
- <footnote_reference id="id4" refname="3">
- 3
- is 3,
- <footnote_reference auto="1" id="id5">
- should be 6, \n\
- <footnote_reference auto="1" id="id6">
- is one too many,
- <footnote_reference auto="1" id="id7" refname="five">
- should be 5, and \n\
- <footnote_reference auto="1" id="id8" refname="six">
- doesn't exist.
- <footnote id="id9" name="1">
- <label>
- 1
- <paragraph>
- Manually-numbered footnote 1.
- <footnote auto="1" id="id10">
- <paragraph>
- Auto-numbered footnote 2.
- <footnote auto="1" id="four" name="four">
- <paragraph>
- Auto-numbered footnote 4.
- <footnote id="id11" name="3">
- <label>
- 3
- <paragraph>
- Manually-numbered footnote 3
- <footnote auto="1" dupname="five" id="five">
- <paragraph>
- Auto-numbered footnote 5.
- <footnote auto="1" dupname="five" id="id12">
- <system_message backrefs="id12" level="2" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "five".
- <paragraph>
- Auto-numbered footnote 5 again (duplicate).
- <footnote auto="1" id="id13">
- <paragraph>
- Auto-numbered footnote 6.
-"""],
-]
-
-totest['auto_symbol_footnotes'] = [
-["""\
-.. [*] This is an auto-symbol footnote.
-""",
-"""\
-<document>
- <footnote auto="*" id="id1">
- <paragraph>
- This is an auto-symbol footnote.
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_functions.py b/docutils/test/test_parsers/test_rst/test_functions.py
deleted file mode 100755
index 2cf7c6a7e..000000000
--- a/docutils/test/test_parsers/test_rst/test_functions.py
+++ /dev/null
@@ -1,38 +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 states.py.
-"""
-
-import unittest
-from __init__ import DocutilsTestSupport
-states = DocutilsTestSupport.states
-
-
-class FuctionTests(unittest.TestCase):
-
- escaped = r'escapes: \*one, \\*two, \\\*three'
- nulled = 'escapes: \x00*one, \x00\\*two, \x00\\\x00*three'
- unescaped = r'escapes: *one, \*two, \*three'
-
- def test_escape2null(self):
- nulled = states.escape2null(self.escaped)
- self.assertEquals(nulled, self.nulled)
- nulled = states.escape2null(self.escaped + '\\')
- self.assertEquals(nulled, self.nulled + '\x00')
-
- def test_unescape(self):
- unescaped = states.unescape(self.nulled)
- self.assertEquals(unescaped, self.unescaped)
- restored = states.unescape(self.nulled, 1)
- self.assertEquals(restored, self.escaped)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/docutils/test/test_parsers/test_rst/test_inline_markup.py b/docutils/test/test_parsers/test_rst/test_inline_markup.py
deleted file mode 100755
index 4a1c3e4c6..000000000
--- a/docutils/test/test_parsers/test_rst/test_inline_markup.py
+++ /dev/null
@@ -1,756 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['emphasis'] = [
-["""\
-*emphasis*
-""",
-"""\
-<document>
- <paragraph>
- <emphasis>
- emphasis
-"""],
-["""\
-*emphasized sentence
-across lines*
-""",
-"""\
-<document>
- <paragraph>
- <emphasis>
- emphasized sentence
- across lines
-"""],
-["""\
-*emphasis without closing asterisk
-""",
-"""\
-<document>
- <paragraph>
- <problematic id="id2" refid="id1">
- *
- emphasis without closing asterisk
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline emphasis start-string without end-string at line 1.
-"""],
-["""\
-'*emphasis*' but not '*' or '"*"' or x*2* or 2*x* or \\*args or *
-or *the\\* *stars\\\\\\* *inside*
-
-(however, '*args' will trigger a warning and may be problematic)
-
-what about *this**?
-""",
-"""\
-<document>
- <paragraph>
- '
- <emphasis>
- emphasis
- ' but not '*' or '"*"' or x*2* or 2*x* or *args or *
- or \n\
- <emphasis>
- the* *stars\* *inside
- <paragraph>
- (however, '
- <problematic id="id2" refid="id1">
- *
- args' will trigger a warning and may be problematic)
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline emphasis start-string without end-string at line 4.
- <paragraph>
- what about \n\
- <emphasis>
- this*
- ?
-"""],
-["""\
-Emphasized asterisk: *\\**
-
-Emphasized double asterisk: *\\***
-""",
-"""\
-<document>
- <paragraph>
- Emphasized asterisk: \n\
- <emphasis>
- *
- <paragraph>
- Emphasized double asterisk: \n\
- <emphasis>
- **
-"""],
-]
-
-totest['strong'] = [
-["""\
-**strong**
-""",
-"""\
-<document>
- <paragraph>
- <strong>
- strong
-"""],
-["""\
-(**strong**) but not (**) or '(** ' or x**2 or \\**kwargs or **
-
-(however, '**kwargs' will trigger a warning and may be problematic)
-""",
-"""\
-<document>
- <paragraph>
- (
- <strong>
- strong
- ) but not (**) or '(** ' or x**2 or **kwargs or **
- <paragraph>
- (however, '
- <problematic id="id2" refid="id1">
- **
- kwargs' will trigger a warning and may be problematic)
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline strong start-string without end-string at line 3.
-"""],
-["""\
-Strong asterisk: *****
-
-Strong double asterisk: ******
-""",
-"""\
-<document>
- <paragraph>
- Strong asterisk: \n\
- <strong>
- *
- <paragraph>
- Strong double asterisk: \n\
- <strong>
- **
-"""],
-["""\
-**strong without closing asterisks
-""",
-"""\
-<document>
- <paragraph>
- <problematic id="id2" refid="id1">
- **
- strong without closing asterisks
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline strong start-string without end-string at line 1.
-"""],
-]
-
-totest['literal'] = [
-["""\
-``literal``
-""",
-"""\
-<document>
- <paragraph>
- <literal>
- literal
-"""],
-["""\
-``\\literal``
-""",
-"""\
-<document>
- <paragraph>
- <literal>
- \\literal
-"""],
-["""\
-``lite\\ral``
-""",
-"""\
-<document>
- <paragraph>
- <literal>
- lite\\ral
-"""],
-["""\
-``literal\\``
-""",
-"""\
-<document>
- <paragraph>
- <literal>
- literal\\
-"""],
-["""\
-``literal ``TeX quotes'' & \\backslash`` but not "``" or ``
-
-(however, ``standalone TeX quotes'' will trigger a warning
-and may be problematic)
-""",
-"""\
-<document>
- <paragraph>
- <literal>
- literal ``TeX quotes'' & \\backslash
- but not "``" or ``
- <paragraph>
- (however, \n\
- <problematic id="id2" refid="id1">
- ``
- standalone TeX quotes'' will trigger a warning
- and may be problematic)
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline literal start-string without end-string at line 3.
-"""],
-["""\
-Find the ```interpreted text``` in this paragraph!
-""",
-"""\
-<document>
- <paragraph>
- Find the \n\
- <literal>
- `interpreted text`
- in this paragraph!
-"""],
-["""\
-``literal without closing backquotes
-""",
-"""\
-<document>
- <paragraph>
- <problematic id="id2" refid="id1">
- ``
- literal without closing backquotes
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline literal start-string without end-string at line 1.
-"""],
-]
-
-totest['interpreted'] = [
-["""\
-`interpreted`
-""",
-"""\
-<document>
- <paragraph>
- <interpreted>
- interpreted
-"""],
-["""\
-:role:`interpreted`
-""",
-"""\
-<document>
- <paragraph>
- <interpreted position="prefix" role="role">
- interpreted
-"""],
-["""\
-`interpreted`:role:
-""",
-"""\
-<document>
- <paragraph>
- <interpreted position="suffix" role="role">
- interpreted
-"""],
-["""\
-:role:`:not-role: interpreted`
-""",
-"""\
-<document>
- <paragraph>
- <interpreted position="prefix" role="role">
- :not-role: interpreted
-"""],
-["""\
-:very.long-role_name:`interpreted`
-""",
-"""\
-<document>
- <paragraph>
- <interpreted position="prefix" role="very.long-role_name">
- interpreted
-"""],
-["""\
-`interpreted` but not \\`interpreted` [`] or ({[`] or [`]}) or `
-""",
-"""\
-<document>
- <paragraph>
- <interpreted>
- interpreted
- but not `interpreted` [`] or ({[`] or [`]}) or `
-"""],
-["""\
-`interpreted`-text `interpreted`: text `interpreted`:text `text`'s interpreted
-""",
-"""\
-<document>
- <paragraph>
- <interpreted>
- interpreted
- -text \n\
- <interpreted>
- interpreted
- : text \n\
- <interpreted>
- interpreted
- :text \n\
- <interpreted>
- text
- 's interpreted
-"""],
-["""\
-`interpreted without closing backquote
-""",
-"""\
-<document>
- <paragraph>
- <problematic id="id2" refid="id1">
- `
- interpreted without closing backquote
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline interpreted text or phrase reference start-string without end-string at line 1.
-"""],
-]
-
-totest['references'] = [
-["""\
-ref_
-""",
-"""\
-<document>
- <paragraph>
- <reference refname="ref">
- ref
-"""],
-["""\
-ref__
-""",
-"""\
-<document>
- <paragraph>
- <reference anonymous="1">
- ref
-"""],
-["""\
-ref_, r_, r_e-f_, and anonymousref__, but not _ref_ or -ref_
-""",
-"""\
-<document>
- <paragraph>
- <reference refname="ref">
- ref
- , \n\
- <reference refname="r">
- r
- , \n\
- <reference refname="r_e-f">
- r_e-f
- , and \n\
- <reference anonymous="1">
- anonymousref
- , but not _ref_ or -ref_
-"""],
-]
-
-totest['phrase_references'] = [
-["""\
-`phrase reference`_
-""",
-"""\
-<document>
- <paragraph>
- <reference refname="phrase reference">
- phrase reference
-"""],
-["""\
-`anonymous reference`__
-""",
-"""\
-<document>
- <paragraph>
- <reference anonymous="1">
- anonymous reference
-"""],
-["""\
-`phrase reference
-across lines`_
-""",
-"""\
-<document>
- <paragraph>
- <reference refname="phrase reference across lines">
- phrase reference
- across lines
-"""],
-["""\
-`phrase\`_ reference`_
-""",
-"""\
-<document>
- <paragraph>
- <reference refname="phrase`_ reference">
- phrase`_ reference
-"""],
-["""\
-Invalid phrase reference:
-
-:role:`phrase reference`_
-""",
-"""\
-<document>
- <paragraph>
- Invalid phrase reference:
- <paragraph>
- :role:
- <problematic id="id2" refid="id1">
- `
- phrase reference`_
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Mismatch: inline interpreted text start-string and role with phrase-reference end-string at line 3.
-"""],
-["""\
-Invalid phrase reference:
-
-`phrase reference`:role:_
-""",
-"""\
-<document>
- <paragraph>
- Invalid phrase reference:
- <paragraph>
- <interpreted>
- phrase reference
- :role:_
-"""],
-["""\
-`phrase reference_ without closing backquote
-""",
-"""\
-<document>
- <paragraph>
- <problematic id="id2" refid="id1">
- `
- phrase \n\
- <reference refname="reference">
- reference
- without closing backquote
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline interpreted text or phrase reference start-string without end-string at line 1.
-"""],
-["""\
-`anonymous phrase reference__ without closing backquote
-""",
-"""\
-<document>
- <paragraph>
- <problematic id="id2" refid="id1">
- `
- anonymous phrase \n\
- <reference anonymous="1">
- reference
- without closing backquote
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline interpreted text or phrase reference start-string without end-string at line 1.
-"""],
-]
-
-totest['inline_targets'] = [
-["""\
-_`target`
-
-Here is _`another target` in some text. And _`yet
-another target`, spanning lines.
-
-_`Here is a TaRgeT` with case and spacial difficulties.
-""",
-"""\
-<document>
- <paragraph>
- <target id="target" name="target">
- target
- <paragraph>
- Here is \n\
- <target id="another-target" name="another target">
- another target
- in some text. And \n\
- <target id="yet-another-target" name="yet another target">
- yet
- another target
- , spanning lines.
- <paragraph>
- <target id="here-is-a-target" name="here is a target">
- Here is a TaRgeT
- with case and spacial difficulties.
-"""],
-["""\
-But this isn't a _target; targets require backquotes.
-
-And _`this`_ is just plain confusing.
-""",
-"""\
-<document>
- <paragraph>
- But this isn't a _target; targets require backquotes.
- <paragraph>
- And \n\
- <problematic id="id2" refid="id1">
- _`
- this`_ is just plain confusing.
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline target start-string without end-string at line 3.
-"""],
-["""\
-_`inline target without closing backquote
-""",
-"""\
-<document>
- <paragraph>
- <problematic id="id2" refid="id1">
- _`
- inline target without closing backquote
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline target start-string without end-string at line 1.
-"""],
-]
-
-totest['footnote_reference'] = [
-["""\
-[1]_
-""",
-"""\
-<document>
- <paragraph>
- <footnote_reference id="id1" refname="1">
- 1
-"""],
-["""\
-[#]_
-""",
-"""\
-<document>
- <paragraph>
- <footnote_reference auto="1" id="id1">
-"""],
-["""\
-[#label]_
-""",
-"""\
-<document>
- <paragraph>
- <footnote_reference auto="1" id="id1" refname="label">
-"""],
-["""\
-[*]_
-""",
-"""\
-<document>
- <paragraph>
- <footnote_reference auto="*" id="id1">
-"""],
-]
-
-totest['citation_reference'] = [
-["""\
-[citation]_
-""",
-"""\
-<document>
- <paragraph>
- <citation_reference id="id1" refname="citation">
- citation
-"""],
-["""\
-[citation]_ and [cit-ation]_ and [cit.ation]_ and [CIT1]_ but not [CIT 1]_
-""",
-"""\
-<document>
- <paragraph>
- <citation_reference id="id1" refname="citation">
- citation
- and \n\
- <citation_reference id="id2" refname="cit-ation">
- cit-ation
- and \n\
- <citation_reference id="id3" refname="cit.ation">
- cit.ation
- and \n\
- <citation_reference id="id4" refname="cit1">
- CIT1
- but not [CIT 1]_
-"""],
-]
-
-totest['substitution_references'] = [
-["""\
-|subref|
-""",
-"""\
-<document>
- <paragraph>
- <substitution_reference refname="subref">
- subref
-"""],
-["""\
-|subref|_ and |subref|__
-""",
-"""\
-<document>
- <paragraph>
- <reference refname="subref">
- <substitution_reference refname="subref">
- subref
- and \n\
- <reference anonymous="1">
- <substitution_reference refname="subref">
- subref
-"""],
-["""\
-|substitution reference|
-""",
-"""\
-<document>
- <paragraph>
- <substitution_reference refname="substitution reference">
- substitution reference
-"""],
-["""\
-|substitution
-reference|
-""",
-"""\
-<document>
- <paragraph>
- <substitution_reference refname="substitution reference">
- substitution
- reference
-"""],
-["""\
-|substitution reference without closing verbar
-""",
-"""\
-<document>
- <paragraph>
- <problematic id="id2" refid="id1">
- |
- substitution reference without closing verbar
- <system_message backrefs="id2" id="id1" level="2" type="WARNING">
- <paragraph>
- Inline substitution_reference start-string without end-string at line 1.
-"""],
-]
-
-totest['standalone_hyperlink'] = [
-["""\
-http://www.standalone.hyperlink.com
-
-http:/one-slash-only.absolute.path
-
-http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html
-
-http://[3ffe:2a00:100:7031::1]
-
-mailto:someone@somewhere.com
-
-news:comp.lang.python
-
-An email address in a sentence: someone@somewhere.com.
-
-ftp://ends.with.a.period.
-
-(a.question.mark@end?)
-""",
-"""\
-<document>
- <paragraph>
- <reference refuri="http://www.standalone.hyperlink.com">
- http://www.standalone.hyperlink.com
- <paragraph>
- <reference refuri="http:/one-slash-only.absolute.path">
- http:/one-slash-only.absolute.path
- <paragraph>
- <reference refuri="http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html">
- http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html
- <paragraph>
- <reference refuri="http://[3ffe:2a00:100:7031::1]">
- http://[3ffe:2a00:100:7031::1]
- <paragraph>
- <reference refuri="mailto:someone@somewhere.com">
- mailto:someone@somewhere.com
- <paragraph>
- <reference refuri="news:comp.lang.python">
- news:comp.lang.python
- <paragraph>
- An email address in a sentence: \n\
- <reference refuri="mailto:someone@somewhere.com">
- someone@somewhere.com
- .
- <paragraph>
- <reference refuri="ftp://ends.with.a.period">
- ftp://ends.with.a.period
- .
- <paragraph>
- (
- <reference refuri="mailto:a.question.mark@end">
- a.question.mark@end
- ?)
-"""],
-["""\
-None of these are standalone hyperlinks (their "schemes"
-are not recognized): signal:noise, a:b.
-""",
-"""\
-<document>
- <paragraph>
- None of these are standalone hyperlinks (their "schemes"
- are not recognized): signal:noise, a:b.
-"""],
-]
-
-totest['miscellaneous'] = [
-["""\
-__This__ should be left alone.
-""",
-"""\
-<document>
- <paragraph>
- __This__ should be left alone.
-"""],
-]
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_literal_blocks.py b/docutils/test/test_parsers/test_rst/test_literal_blocks.py
deleted file mode 100755
index 651733b09..000000000
--- a/docutils/test/test_parsers/test_rst/test_literal_blocks.py
+++ /dev/null
@@ -1,190 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['literal_blocks'] = [
-["""\
-A paragraph::
-
- A literal block.
-""",
-"""\
-<document>
- <paragraph>
- A paragraph:
- <literal_block>
- A literal block.
-"""],
-["""\
-A paragraph::
-
- A literal block.
-
-Another paragraph::
-
- Another literal block.
- With two blank lines following.
-
-
-A final paragraph.
-""",
-"""\
-<document>
- <paragraph>
- A paragraph:
- <literal_block>
- A literal block.
- <paragraph>
- Another paragraph:
- <literal_block>
- Another literal block.
- With two blank lines following.
- <paragraph>
- A final paragraph.
-"""],
-["""\
-A paragraph
-on more than
-one line::
-
- A literal block.
-""",
-"""\
-<document>
- <paragraph>
- A paragraph
- on more than
- one line:
- <literal_block>
- A literal block.
-"""],
-["""\
-A paragraph
-on more than
-one line::
- A literal block
- with no blank line above.
-""",
-"""\
-<document>
- <paragraph>
- A paragraph
- on more than
- one line:
- <system_message level="3" type="ERROR">
- <paragraph>
- Unexpected indentation at line 4.
- <literal_block>
- A literal block
- with no blank line above.
-"""],
-["""\
-A paragraph::
-
- A literal block.
-no blank line
-""",
-"""\
-<document>
- <paragraph>
- A paragraph:
- <literal_block>
- A literal block.
- <system_message level="2" type="WARNING">
- <paragraph>
- Literal block ends without a blank line; unexpected unindent at line 4.
- <paragraph>
- no blank line
-"""],
-["""\
-A paragraph: ::
-
- A literal block.
-""",
-"""\
-<document>
- <paragraph>
- A paragraph:
- <literal_block>
- A literal block.
-"""],
-["""\
-A paragraph:
-
-::
-
- A literal block.
-""",
-"""\
-<document>
- <paragraph>
- A paragraph:
- <literal_block>
- A literal block.
-"""],
-["""\
-A paragraph::
-
-Not a literal block.
-""",
-"""\
-<document>
- <paragraph>
- A paragraph:
- <system_message level="2" type="WARNING">
- <paragraph>
- Literal block expected at line 2; none found.
- <paragraph>
- Not a literal block.
-"""],
-["""\
-A paragraph::
-
- A wonky literal block.
- Literal line 2.
-
- Literal line 3.
-""",
-"""\
-<document>
- <paragraph>
- A paragraph:
- <literal_block>
- A wonky literal block.
- Literal line 2.
- \n\
- Literal line 3.
-"""],
-["""\
-EOF, even though a literal block is indicated::
-""",
-"""\
-<document>
- <paragraph>
- EOF, even though a literal block is indicated:
- <system_message level="2" type="WARNING">
- <paragraph>
- Literal block expected at line 2; none found.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_option_lists.py b/docutils/test/test_parsers/test_rst/test_option_lists.py
deleted file mode 100755
index bbabe51a6..000000000
--- a/docutils/test/test_parsers/test_rst/test_option_lists.py
+++ /dev/null
@@ -1,684 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['option_lists'] = [
-["""\
-Short options:
-
--a option -a
-
--b file option -b
-
--c name option -c
-""",
-"""\
-<document>
- <paragraph>
- Short options:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -a
- <description>
- <paragraph>
- option -a
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -b
- <option_argument delimiter=" ">
- file
- <description>
- <paragraph>
- option -b
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -c
- <option_argument delimiter=" ">
- name
- <description>
- <paragraph>
- option -c
-"""],
-["""\
-Long options:
-
---aaaa option --aaaa
---bbbb=file option --bbbb
---cccc name option --cccc
---d-e-f-g option --d-e-f-g
---h_i_j_k option --h_i_j_k
-""",
-"""\
-<document>
- <paragraph>
- Long options:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --aaaa
- <description>
- <paragraph>
- option --aaaa
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --bbbb
- <option_argument delimiter="=">
- file
- <description>
- <paragraph>
- option --bbbb
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --cccc
- <option_argument delimiter=" ">
- name
- <description>
- <paragraph>
- option --cccc
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --d-e-f-g
- <description>
- <paragraph>
- option --d-e-f-g
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --h_i_j_k
- <description>
- <paragraph>
- option --h_i_j_k
-"""],
-["""\
-Old GNU-style options:
-
-+a option +a
-
-+b file option +b
-
-+c name option +c
-""",
-"""\
-<document>
- <paragraph>
- Old GNU-style options:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- +a
- <description>
- <paragraph>
- option +a
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- +b
- <option_argument delimiter=" ">
- file
- <description>
- <paragraph>
- option +b
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- +c
- <option_argument delimiter=" ">
- name
- <description>
- <paragraph>
- option +c
-"""],
-["""\
-VMS/DOS-style options:
-
-/A option /A
-/B file option /B
-/CCC option /CCC
-/DDD string option /DDD
-/EEE=int option /EEE
-""",
-"""\
-<document>
- <paragraph>
- VMS/DOS-style options:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- /A
- <description>
- <paragraph>
- option /A
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- /B
- <option_argument delimiter=" ">
- file
- <description>
- <paragraph>
- option /B
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- /CCC
- <description>
- <paragraph>
- option /CCC
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- /DDD
- <option_argument delimiter=" ">
- string
- <description>
- <paragraph>
- option /DDD
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- /EEE
- <option_argument delimiter="=">
- int
- <description>
- <paragraph>
- option /EEE
-"""],
-["""\
-Mixed short, long, and VMS/DOS options:
-
--a option -a
---bbbb=file option -bbbb
-/C option /C
---dddd name option --dddd
--e string option -e
-/F file option /F
-""",
-"""\
-<document>
- <paragraph>
- Mixed short, long, and VMS/DOS options:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -a
- <description>
- <paragraph>
- option -a
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --bbbb
- <option_argument delimiter="=">
- file
- <description>
- <paragraph>
- option -bbbb
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- /C
- <description>
- <paragraph>
- option /C
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --dddd
- <option_argument delimiter=" ">
- name
- <description>
- <paragraph>
- option --dddd
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -e
- <option_argument delimiter=" ">
- string
- <description>
- <paragraph>
- option -e
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- /F
- <option_argument delimiter=" ">
- file
- <description>
- <paragraph>
- option /F
-"""],
-["""\
-Aliased options:
-
--a, --aaaa, /A option -a, --aaaa, /A
--b file, --bbbb=file, /B file option -b, --bbbb, /B
-""",
-"""\
-<document>
- <paragraph>
- Aliased options:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -a
- <option>
- <option_string>
- --aaaa
- <option>
- <option_string>
- /A
- <description>
- <paragraph>
- option -a, --aaaa, /A
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -b
- <option_argument delimiter=" ">
- file
- <option>
- <option_string>
- --bbbb
- <option_argument delimiter="=">
- file
- <option>
- <option_string>
- /B
- <option_argument delimiter=" ">
- file
- <description>
- <paragraph>
- option -b, --bbbb, /B
-"""],
-["""\
-Multiple lines in descriptions, aligned:
-
--a option -a, line 1
- line 2
--b file option -b, line 1
- line 2
-""",
-"""\
-<document>
- <paragraph>
- Multiple lines in descriptions, aligned:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -a
- <description>
- <paragraph>
- option -a, line 1
- line 2
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -b
- <option_argument delimiter=" ">
- file
- <description>
- <paragraph>
- option -b, line 1
- line 2
-"""],
-["""\
-Multiple lines in descriptions, not aligned:
-
--a option -a, line 1
- line 2
--b file option -b, line 1
- line 2
-""",
-"""\
-<document>
- <paragraph>
- Multiple lines in descriptions, not aligned:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -a
- <description>
- <paragraph>
- option -a, line 1
- line 2
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -b
- <option_argument delimiter=" ">
- file
- <description>
- <paragraph>
- option -b, line 1
- line 2
-"""],
-["""\
-Descriptions begin on next line:
-
--a
- option -a, line 1
- line 2
--b file
- option -b, line 1
- line 2
-""",
-"""\
-<document>
- <paragraph>
- Descriptions begin on next line:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -a
- <description>
- <paragraph>
- option -a, line 1
- line 2
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -b
- <option_argument delimiter=" ">
- file
- <description>
- <paragraph>
- option -b, line 1
- line 2
-"""],
-["""\
-Multiple body elements in descriptions:
-
--a option -a, para 1
-
- para 2
--b file
- option -b, para 1
-
- para 2
-""",
-"""\
-<document>
- <paragraph>
- Multiple body elements in descriptions:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -a
- <description>
- <paragraph>
- option -a, para 1
- <paragraph>
- para 2
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- -b
- <option_argument delimiter=" ">
- file
- <description>
- <paragraph>
- option -b, para 1
- <paragraph>
- para 2
-"""],
-["""\
---option
-empty item above, no blank line
-""",
-"""\
-<document>
- <paragraph>
- --option
- empty item above, no blank line
-"""],
-["""\
-An option list using equals:
-
---long1=arg1 Description 1
---long2=arg2 Description 2
-
-An option list using spaces:
-
---long1 arg1 Description 1
---long2 arg2 Description 2
-
-An option list using mixed delimiters:
-
---long1=arg1 Description 1
---long2 arg2 Description 2
-
-An option list using mixed delimiters in one line:
-
---long1=arg1, --long2 arg2 Description
-""",
-"""\
-<document>
- <paragraph>
- An option list using equals:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --long1
- <option_argument delimiter="=">
- arg1
- <description>
- <paragraph>
- Description 1
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --long2
- <option_argument delimiter="=">
- arg2
- <description>
- <paragraph>
- Description 2
- <paragraph>
- An option list using spaces:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --long1
- <option_argument delimiter=" ">
- arg1
- <description>
- <paragraph>
- Description 1
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --long2
- <option_argument delimiter=" ">
- arg2
- <description>
- <paragraph>
- Description 2
- <paragraph>
- An option list using mixed delimiters:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --long1
- <option_argument delimiter="=">
- arg1
- <description>
- <paragraph>
- Description 1
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --long2
- <option_argument delimiter=" ">
- arg2
- <description>
- <paragraph>
- Description 2
- <paragraph>
- An option list using mixed delimiters in one line:
- <option_list>
- <option_list_item>
- <option_group>
- <option>
- <option_string>
- --long1
- <option_argument delimiter="=">
- arg1
- <option>
- <option_string>
- --long2
- <option_argument delimiter=" ">
- arg2
- <description>
- <paragraph>
- Description
-"""],
-["""\
-Some edge cases:
-
---option=arg arg too many arguments
-
---option=arg,arg not supported (yet?)
-
---option=arg=arg too many arguments
-
---option arg arg too many arguments
-
--a letter arg2 too many arguments
-
-/A letter arg2 too many arguments
-
---option= argument missing
-
---=argument option missing
-
--- everything missing
-
-- this should be a bullet list item
-
-These next ones should be simple paragraphs:
-
--1
-
---option
-
---1
-
--1 and this one too.
-""",
-"""\
-<document>
- <paragraph>
- Some edge cases:
- <paragraph>
- --option=arg arg too many arguments
- <paragraph>
- --option=arg,arg not supported (yet?)
- <paragraph>
- --option=arg=arg too many arguments
- <paragraph>
- --option arg arg too many arguments
- <paragraph>
- -a letter arg2 too many arguments
- <paragraph>
- /A letter arg2 too many arguments
- <paragraph>
- --option= argument missing
- <paragraph>
- --=argument option missing
- <paragraph>
- -- everything missing
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- this should be a bullet list item
- <paragraph>
- These next ones should be simple paragraphs:
- <paragraph>
- -1
- <paragraph>
- --option
- <paragraph>
- --1
- <paragraph>
- -1 and this one too.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_outdenting.py b/docutils/test/test_parsers/test_rst/test_outdenting.py
deleted file mode 100755
index 314c50837..000000000
--- a/docutils/test/test_parsers/test_rst/test_outdenting.py
+++ /dev/null
@@ -1,90 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['outdenting'] = [
-["""\
-Anywhere a paragraph would have an effect on the current
-indentation level, a comment or list item should also.
-
-+ bullet
-
-This paragraph ends the bullet list item before a block quote.
-
- Block quote.
-""",
-"""\
-<document>
- <paragraph>
- Anywhere a paragraph would have an effect on the current
- indentation level, a comment or list item should also.
- <bullet_list bullet="+">
- <list_item>
- <paragraph>
- bullet
- <paragraph>
- This paragraph ends the bullet list item before a block quote.
- <block_quote>
- <paragraph>
- Block quote.
-"""],
-["""\
-+ bullet
-
-.. Comments swallow up all indented text following.
-
- (Therefore this is not a) block quote.
-
-- bullet
-
- If we want a block quote after this bullet list item,
- we need to use an empty comment:
-
-..
-
- Block quote.
-""",
-"""\
-<document>
- <bullet_list bullet="+">
- <list_item>
- <paragraph>
- bullet
- <comment>
- Comments swallow up all indented text following.
- \n\
- (Therefore this is not a) block quote.
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- bullet
- <paragraph>
- If we want a block quote after this bullet list item,
- we need to use an empty comment:
- <comment>
- <block_quote>
- <paragraph>
- Block quote.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_paragraphs.py b/docutils/test/test_parsers/test_rst/test_paragraphs.py
deleted file mode 100755
index d1f3a324a..000000000
--- a/docutils/test/test_parsers/test_rst/test_paragraphs.py
+++ /dev/null
@@ -1,79 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['paragraphs'] = [
-["""\
-A paragraph.
-""",
-"""\
-<document>
- <paragraph>
- A paragraph.
-"""],
-["""\
-Paragraph 1.
-
-Paragraph 2.
-""",
-"""\
-<document>
- <paragraph>
- Paragraph 1.
- <paragraph>
- Paragraph 2.
-"""],
-["""\
-Line 1.
-Line 2.
-Line 3.
-""",
-"""\
-<document>
- <paragraph>
- Line 1.
- Line 2.
- Line 3.
-"""],
-["""\
-Paragraph 1, Line 1.
-Line 2.
-Line 3.
-
-Paragraph 2, Line 1.
-Line 2.
-Line 3.
-""",
-"""\
-<document>
- <paragraph>
- Paragraph 1, Line 1.
- Line 2.
- Line 3.
- <paragraph>
- Paragraph 2, Line 1.
- Line 2.
- Line 3.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_rfc2822.py b/docutils/test/test_parsers/test_rst/test_rfc2822.py
deleted file mode 100755
index 754c47586..000000000
--- a/docutils/test/test_parsers/test_rst/test_rfc2822.py
+++ /dev/null
@@ -1,260 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.RFC2822ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['rfc2822'] = [
-["""\
-Author: Me
-Version: 1
-Date: 2002-04-23
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- Author
- <field_body>
- <paragraph>
- Me
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2002-04-23
-"""],
-["""\
-Author: Me
-Version: 1
-Date: 2002-04-23
-
-Leading blank lines don't affect RFC-2822 header parsing.
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- Author
- <field_body>
- <paragraph>
- Me
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2002-04-23
- <paragraph>
- Leading blank lines don't affect RFC-2822 header parsing.
-"""],
-["""\
-.. A comment should prevent RFC-2822 header parsing.
-
-Author: Me
-Version: 1
-Date: 2002-04-23
-""",
-"""\
-<document>
- <comment>
- A comment should prevent RFC-2822 header parsing.
- <paragraph>
- Author: Me
- Version: 1
- Date: 2002-04-23
-"""],
-["""\
-Author: Me
-
-Version: 1
-Date: 2002-04-23
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- Author
- <field_body>
- <paragraph>
- Me
- <paragraph>
- Version: 1
- Date: 2002-04-23
-"""],
-["""\
-field:
-empty item above, no blank line
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- field
- <field_body>
- <system_message level="2" type="WARNING">
- <paragraph>
- RFC2822-style field list ends without a blank line; unexpected unindent at line 2.
- <paragraph>
- empty item above, no blank line
-"""],
-["""\
-Author:
- Me
-Version:
- 1
-Date:
- 2002-04-23
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- Author
- <field_body>
- <paragraph>
- Me
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2002-04-23
-"""],
-["""\
-Authors: Me,
- Myself,
- and I
-Version: 1
- or so
-Date: 2002-04-23
- (Tuesday)
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- Authors
- <field_body>
- <paragraph>
- Me,
- Myself,
- and I
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- or so
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2002-04-23
- (Tuesday)
-"""],
-["""\
-Authors: Me,
- Myself,
- and I
-Version: 1
- or so
-Date: 2002-04-23
- (Tuesday)
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- Authors
- <field_body>
- <paragraph>
- Me,
- Myself,
- and I
- <field>
- <field_name>
- Version
- <field_body>
- <paragraph>
- 1
- or so
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- 2002-04-23
- (Tuesday)
-"""],
-["""\
-Authors: - Me
- - Myself
- - I
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- Authors
- <field_body>
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- Me
- <list_item>
- <paragraph>
- Myself
- <list_item>
- <paragraph>
- I
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_section_headers.py b/docutils/test/test_parsers/test_rst/test_section_headers.py
deleted file mode 100755
index 54c556623..000000000
--- a/docutils/test/test_parsers/test_rst/test_section_headers.py
+++ /dev/null
@@ -1,555 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['section_headers'] = [
-["""\
-Title
-=====
-
-Paragraph.
-""",
-"""\
-<document>
- <section id="title" name="title">
- <title>
- Title
- <paragraph>
- Paragraph.
-"""],
-["""\
-Title
-=====
-Paragraph (no blank line).
-""",
-"""\
-<document>
- <section id="title" name="title">
- <title>
- Title
- <paragraph>
- Paragraph (no blank line).
-"""],
-["""\
-Paragraph.
-
-Title
-=====
-
-Paragraph.
-""",
-"""\
-<document>
- <paragraph>
- Paragraph.
- <section id="title" name="title">
- <title>
- Title
- <paragraph>
- Paragraph.
-"""],
-["""\
-Test unexpected section titles.
-
- Title
- =====
- Paragraph.
-
- -----
- Title
- -----
- Paragraph.
-""",
-"""\
-<document>
- <paragraph>
- Test unexpected section titles.
- <block_quote>
- <system_message level="4" type="SEVERE">
- <paragraph>
- Unexpected section title at line 4.
- <literal_block>
- Title
- =====
- <paragraph>
- Paragraph.
- <system_message level="4" type="SEVERE">
- <paragraph>
- Unexpected section title or transition at line 7.
- <literal_block>
- -----
- <system_message level="4" type="SEVERE">
- <paragraph>
- Unexpected section title at line 9.
- <literal_block>
- Title
- -----
- <paragraph>
- Paragraph.
-"""],
-["""\
-Title
-====
-
-Test short underline.
-""",
-"""\
-<document>
- <system_message level="1" type="INFO">
- <paragraph>
- Title underline too short at line 2.
- <literal_block>
- Title
- ====
- <section id="title" name="title">
- <title>
- Title
- <paragraph>
- Test short underline.
-"""],
-["""\
-=====
-Title
-=====
-
-Test overline title.
-""",
-"""\
-<document>
- <section id="title" name="title">
- <title>
- Title
- <paragraph>
- Test overline title.
-"""],
-["""\
-=======
- Title
-=======
-
-Test overline title with inset.
-""",
-"""\
-<document>
- <section id="title" name="title">
- <title>
- Title
- <paragraph>
- Test overline title with inset.
-"""],
-["""\
-========================
- Test Missing Underline
-""",
-"""\
-<document>
- <system_message level="4" type="SEVERE">
- <paragraph>
- Incomplete section title at line 1.
- <literal_block>
- ========================
- Test Missing Underline
-"""],
-["""\
-========================
- Test Missing Underline
-
-""",
-"""\
-<document>
- <system_message level="4" type="SEVERE">
- <paragraph>
- Missing underline for overline at line 1.
- <literal_block>
- ========================
- Test Missing Underline
-"""],
-["""\
-=======
- Title
-
-Test missing underline, with paragraph.
-""",
-"""\
-<document>
- <system_message level="4" type="SEVERE">
- <paragraph>
- Missing underline for overline at line 1.
- <literal_block>
- =======
- Title
- <paragraph>
- Test missing underline, with paragraph.
-"""],
-["""\
-=======
- Long Title
-=======
-
-Test long title and space normalization.
-""",
-"""\
-<document>
- <system_message level="1" type="INFO">
- <paragraph>
- Title overline too short at line 1.
- <literal_block>
- =======
- Long Title
- =======
- <section id="long-title" name="long title">
- <title>
- Long Title
- <paragraph>
- Test long title and space normalization.
-"""],
-["""\
-=======
- Title
--------
-
-Paragraph.
-""",
-"""\
-<document>
- <system_message level="4" type="SEVERE">
- <paragraph>
- Title overline & underline mismatch at line 1.
- <literal_block>
- =======
- Title
- -------
- <paragraph>
- Paragraph.
-"""],
-["""\
-========================
-
-========================
-
-Test missing titles; blank line in-between.
-
-========================
-
-========================
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Document or section may not begin with a transition (line 1).
- <transition>
- <system_message level="3" type="ERROR">
- <paragraph>
- At least one body element must separate transitions; adjacent transitions at line 3.
- <transition>
- <paragraph>
- Test missing titles; blank line in-between.
- <transition>
- <transition>
- <system_message level="3" type="ERROR">
- <paragraph>
- Document or section may not end with a transition (line 9).
-"""],
-["""\
-========================
-========================
-
-Test missing titles; nothing in-between.
-
-========================
-========================
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Invalid section title or transition marker at line 1.
- <literal_block>
- ========================
- ========================
- <paragraph>
- Test missing titles; nothing in-between.
- <system_message level="3" type="ERROR">
- <paragraph>
- Invalid section title or transition marker at line 6.
- <literal_block>
- ========================
- ========================
-"""],
-["""\
-.. Test return to existing, highest-level section (Title 3).
-
-Title 1
-=======
-Paragraph 1.
-
-Title 2
--------
-Paragraph 2.
-
-Title 3
-=======
-Paragraph 3.
-
-Title 4
--------
-Paragraph 4.
-""",
-"""\
-<document>
- <comment>
- Test return to existing, highest-level section (Title 3).
- <section id="title-1" name="title 1">
- <title>
- Title 1
- <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.
- <section id="title-4" name="title 4">
- <title>
- Title 4
- <paragraph>
- Paragraph 4.
-"""],
-["""\
-Test return to existing, highest-level section (Title 3, with overlines).
-
-=======
-Title 1
-=======
-Paragraph 1.
-
--------
-Title 2
--------
-Paragraph 2.
-
-=======
-Title 3
-=======
-Paragraph 3.
-
--------
-Title 4
--------
-Paragraph 4.
-""",
-"""\
-<document>
- <paragraph>
- Test return to existing, highest-level section (Title 3, with overlines).
- <section id="title-1" name="title 1">
- <title>
- Title 1
- <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.
- <section id="title-4" name="title 4">
- <title>
- Title 4
- <paragraph>
- Paragraph 4.
-"""],
-["""\
-Test return to existing, higher-level section (Title 4).
-
-Title 1
-=======
-Paragraph 1.
-
-Title 2
--------
-Paragraph 2.
-
-Title 3
-```````
-Paragraph 3.
-
-Title 4
--------
-Paragraph 4.
-""",
-"""\
-<document>
- <paragraph>
- Test return to existing, higher-level section (Title 4).
- <section id="title-1" name="title 1">
- <title>
- Title 1
- <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.
- <section id="title-4" name="title 4">
- <title>
- Title 4
- <paragraph>
- Paragraph 4.
-"""],
-["""\
-Test bad subsection order (Title 4).
-
-Title 1
-=======
-Paragraph 1.
-
-Title 2
--------
-Paragraph 2.
-
-Title 3
-=======
-Paragraph 3.
-
-Title 4
-```````
-Paragraph 4.
-""",
-"""\
-<document>
- <paragraph>
- Test bad subsection order (Title 4).
- <section id="title-1" name="title 1">
- <title>
- Title 1
- <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.
- <system_message level="4" type="SEVERE">
- <paragraph>
- Title level inconsistent at line 15:
- <literal_block>
- Title 4
- ```````
- <paragraph>
- Paragraph 4.
-"""],
-["""\
-Test bad subsection order (Title 4, with overlines).
-
-=======
-Title 1
-=======
-Paragraph 1.
-
--------
-Title 2
--------
-Paragraph 2.
-
-=======
-Title 3
-=======
-Paragraph 3.
-
-```````
-Title 4
-```````
-Paragraph 4.
-""",
-"""\
-<document>
- <paragraph>
- Test bad subsection order (Title 4, with overlines).
- <section id="title-1" name="title 1">
- <title>
- Title 1
- <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.
- <system_message level="4" type="SEVERE">
- <paragraph>
- Title level inconsistent at line 19:
- <literal_block>
- ```````
- Title 4
- ```````
- <paragraph>
- Paragraph 4.
-"""],
-["""\
-Title containing *inline* ``markup``
-====================================
-
-Paragraph.
-""",
-"""\
-<document>
- <section id="title-containing-inline-markup" name="title containing inline markup">
- <title>
- Title containing \n\
- <emphasis>
- inline
- \n\
- <literal>
- markup
- <paragraph>
- Paragraph.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_substitutions.py b/docutils/test/test_parsers/test_rst/test_substitutions.py
deleted file mode 100755
index 3f1c34c68..000000000
--- a/docutils/test/test_parsers/test_rst/test_substitutions.py
+++ /dev/null
@@ -1,192 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['substitution_definitions'] = [
-["""\
-Here's an image substitution definition:
-
-.. |symbol| image:: symbol.png
-""",
-"""\
-<document>
- <paragraph>
- Here's an image substitution definition:
- <substitution_definition name="symbol">
- <image alt="symbol" uri="symbol.png">
-"""],
-["""\
-Embedded directive starts on the next line:
-
-.. |symbol|
- image:: symbol.png
-""",
-"""\
-<document>
- <paragraph>
- Embedded directive starts on the next line:
- <substitution_definition name="symbol">
- <image alt="symbol" uri="symbol.png">
-"""],
-["""\
-Here's a series of substitution definitions:
-
-.. |symbol 1| image:: symbol1.png
-.. |SYMBOL 2| image:: symbol2.png
- :height: 50
- :width: 100
-.. |symbol 3| image:: symbol3.png
-""",
-"""\
-<document>
- <paragraph>
- Here's a series of substitution definitions:
- <substitution_definition name="symbol 1">
- <image alt="symbol 1" uri="symbol1.png">
- <substitution_definition name="symbol 2">
- <image alt="SYMBOL 2" height="50" uri="symbol2.png" width="100">
- <substitution_definition name="symbol 3">
- <image alt="symbol 3" uri="symbol3.png">
-"""],
-["""\
-.. |very long substitution text,
- split across lines| image:: symbol.png
-""",
-"""\
-<document>
- <substitution_definition name="very long substitution text, split across lines">
- <image alt="very long substitution text, split across lines" uri="symbol.png">
-"""],
-["""\
-.. |symbol 1| image:: symbol.png
-
-Followed by a paragraph.
-
-.. |symbol 2| image:: symbol.png
-
- Followed by a block quote.
-""",
-"""\
-<document>
- <substitution_definition name="symbol 1">
- <image alt="symbol 1" uri="symbol.png">
- <paragraph>
- Followed by a paragraph.
- <substitution_definition name="symbol 2">
- <image alt="symbol 2" uri="symbol.png">
- <block_quote>
- <paragraph>
- Followed by a block quote.
-"""],
-["""\
-Here are some duplicate substitution definitions:
-
-.. |symbol| image:: symbol.png
-.. |symbol| image:: symbol.png
-""",
-"""\
-<document>
- <paragraph>
- Here are some duplicate substitution definitions:
- <substitution_definition dupname="symbol">
- <image alt="symbol" uri="symbol.png">
- <system_message level="3" type="ERROR">
- <paragraph>
- Duplicate substitution definition name: "symbol".
- <substitution_definition name="symbol">
- <image alt="symbol" uri="symbol.png">
-"""],
-["""\
-Here are some bad cases:
-
-.. |symbol| image:: symbol.png
-No blank line after.
-
-.. |empty|
-
-.. |unknown| directive:: symbol.png
-
-.. |invalid 1| there's no directive here
-.. |invalid 2| there's no directive here
- With some block quote text, line 1.
- And some more, line 2.
-
-.. |invalid 3| there's no directive here
-
-.. | bad name | bad data
-""",
-"""\
-<document>
- <paragraph>
- Here are some bad cases:
- <substitution_definition name="symbol">
- <image alt="symbol" uri="symbol.png">
- <system_message level="2" type="WARNING">
- <paragraph>
- Explicit markup ends without a blank line; unexpected unindent at line 4.
- <paragraph>
- No blank line after.
- <system_message level="2" type="WARNING">
- <paragraph>
- Substitution definition "empty" missing contents at line 6.
- <literal_block>
- .. |empty|
- <system_message level="3" type="ERROR">
- <paragraph>
- Unknown directive type "directive" at line 8.
- <literal_block>
- directive:: symbol.png
- <system_message level="2" type="WARNING">
- <paragraph>
- Substitution definition "unknown" empty or invalid at line 8.
- <literal_block>
- .. |unknown| directive:: symbol.png
- <system_message level="2" type="WARNING">
- <paragraph>
- Substitution definition "invalid 1" empty or invalid at line 10.
- <literal_block>
- .. |invalid 1| there's no directive here
- <system_message level="2" type="WARNING">
- <paragraph>
- Substitution definition "invalid 2" empty or invalid at line 11.
- <literal_block>
- .. |invalid 2| there's no directive here
- With some block quote text, line 1.
- And some more, line 2.
- <system_message level="2" type="WARNING">
- <paragraph>
- Explicit markup ends without a blank line; unexpected unindent at line 12.
- <block_quote>
- <paragraph>
- With some block quote text, line 1.
- And some more, line 2.
- <system_message level="2" type="WARNING">
- <paragraph>
- Substitution definition "invalid 3" empty or invalid at line 15.
- <literal_block>
- .. |invalid 3| there's no directive here
- <comment>
- | bad name | bad data
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_tables.py b/docutils/test/test_parsers/test_rst/test_tables.py
deleted file mode 100755
index b6f1be993..000000000
--- a/docutils/test/test_parsers/test_rst/test_tables.py
+++ /dev/null
@@ -1,564 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['tables'] = [
-["""\
-+-------------------------------------+
-| A table with one cell and one line. |
-+-------------------------------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="1">
- <colspec colwidth="37">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A table with one cell and one line.
-"""],
-["""\
-+-----------------------+
-| A table with one cell |
-| and two lines. |
-+-----------------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="1">
- <colspec colwidth="23">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A table with one cell
- and two lines.
-"""],
-["""\
-+-----------------------+
-| A malformed table. |
-+-----------------------+
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Malformed table at line 1; formatting as a literal block.
- <literal_block>
- +-----------------------+
- | A malformed table. |
- +-----------------------+
-"""],
-["""\
-+------------------------+
-| A well-formed | table. |
-+------------------------+
-
-+------------------------+
-| This +----------+ too! |
-+------------------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="1">
- <colspec colwidth="24">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A well-formed | table.
- <table>
- <tgroup cols="1">
- <colspec colwidth="24">
- <tbody>
- <row>
- <entry>
- <paragraph>
- This +----------+ too!
-"""],
-["""\
-+--------------+--------------+
-| A table with | two columns. |
-+--------------+--------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="2">
- <colspec colwidth="14">
- <colspec colwidth="14">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A table with
- <entry>
- <paragraph>
- two columns.
-"""],
-["""\
-+--------------+
-| A table with |
-+--------------+
-| two rows. |
-+--------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="1">
- <colspec colwidth="14">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A table with
- <row>
- <entry>
- <paragraph>
- two rows.
-"""],
-["""\
-+--------------+-------------+
-| A table with | two columns |
-+--------------+-------------+
-| and | two rows. |
-+--------------+-------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="2">
- <colspec colwidth="14">
- <colspec colwidth="13">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A table with
- <entry>
- <paragraph>
- two columns
- <row>
- <entry>
- <paragraph>
- and
- <entry>
- <paragraph>
- two rows.
-"""],
-["""\
-+--------------+---------------+
-| A table with | two columns, |
-+--------------+---------------+
-| two rows, and a column span. |
-+------------------------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="2">
- <colspec colwidth="14">
- <colspec colwidth="15">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A table with
- <entry>
- <paragraph>
- two columns,
- <row>
- <entry morecols="1">
- <paragraph>
- two rows, and a column span.
-"""],
-["""\
-+--------------------------+
-| A table with three rows, |
-+------------+-------------+
-| and two | columns. |
-+------------+-------------+
-| First and last rows |
-| contains column spans. |
-+--------------------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="2">
- <colspec colwidth="12">
- <colspec colwidth="13">
- <tbody>
- <row>
- <entry morecols="1">
- <paragraph>
- A table with three rows,
- <row>
- <entry>
- <paragraph>
- and two
- <entry>
- <paragraph>
- columns.
- <row>
- <entry morecols="1">
- <paragraph>
- First and last rows
- contains column spans.
-"""],
-["""\
-+--------------+--------------+
-| A table with | two columns, |
-+--------------+ and a row |
-| two rows, | span. |
-+--------------+--------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="2">
- <colspec colwidth="14">
- <colspec colwidth="14">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A table with
- <entry morerows="1">
- <paragraph>
- two columns,
- and a row
- span.
- <row>
- <entry>
- <paragraph>
- two rows,
-"""],
-["""\
-+------------+-------------+---------------+
-| A table | two rows in | and row spans |
-| with three +-------------+ to left and |
-| columns, | the middle, | right. |
-+------------+-------------+---------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="3">
- <colspec colwidth="12">
- <colspec colwidth="13">
- <colspec colwidth="15">
- <tbody>
- <row>
- <entry morerows="1">
- <paragraph>
- A table
- with three
- columns,
- <entry>
- <paragraph>
- two rows in
- <entry morerows="1">
- <paragraph>
- and row spans
- to left and
- right.
- <row>
- <entry>
- <paragraph>
- the middle,
-"""],
-["""\
-Complex spanning pattern (no edge knows all rows/cols):
-
-+-----------+-------------------------+
-| W/NW cell | N/NE cell |
-| +-------------+-----------+
-| | Middle cell | E/SE cell |
-+-----------+-------------+ |
-| S/SE cell | |
-+-------------------------+-----------+
-""",
-"""\
-<document>
- <paragraph>
- Complex spanning pattern (no edge knows all rows/cols):
- <table>
- <tgroup cols="3">
- <colspec colwidth="11">
- <colspec colwidth="13">
- <colspec colwidth="11">
- <tbody>
- <row>
- <entry morerows="1">
- <paragraph>
- W/NW cell
- <entry morecols="1">
- <paragraph>
- N/NE cell
- <row>
- <entry>
- <paragraph>
- Middle cell
- <entry morerows="1">
- <paragraph>
- E/SE cell
- <row>
- <entry morecols="1">
- <paragraph>
- S/SE cell
-"""],
-["""\
-+------------------------+------------+----------+----------+
-| Header row, column 1 | Header 2 | Header 3 | Header 4 |
-+========================+============+==========+==========+
-| body row 1, column 1 | column 2 | column 3 | column 4 |
-+------------------------+------------+----------+----------+
-| body row 2 | Cells may span columns. |
-+------------------------+------------+---------------------+
-| body row 3 | Cells may | - Table cells |
-+------------------------+ span rows. | - contain |
-| body row 4 | | - body elements. |
-+------------------------+------------+---------------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="4">
- <colspec colwidth="24">
- <colspec colwidth="12">
- <colspec colwidth="10">
- <colspec colwidth="10">
- <thead>
- <row>
- <entry>
- <paragraph>
- Header row, column 1
- <entry>
- <paragraph>
- Header 2
- <entry>
- <paragraph>
- Header 3
- <entry>
- <paragraph>
- Header 4
- <tbody>
- <row>
- <entry>
- <paragraph>
- body row 1, column 1
- <entry>
- <paragraph>
- column 2
- <entry>
- <paragraph>
- column 3
- <entry>
- <paragraph>
- column 4
- <row>
- <entry>
- <paragraph>
- body row 2
- <entry morecols="2">
- <paragraph>
- Cells may span columns.
- <row>
- <entry>
- <paragraph>
- body row 3
- <entry morerows="1">
- <paragraph>
- Cells may
- span rows.
- <entry morecols="1" morerows="1">
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- Table cells
- <list_item>
- <paragraph>
- contain
- <list_item>
- <paragraph>
- body elements.
- <row>
- <entry>
- <paragraph>
- body row 4
-"""],
-["""\
-+-----------------+--------+
-| A simple table | cell 2 |
-+-----------------+--------+
-| cell 3 | cell 4 |
-+-----------------+--------+
-No blank line after table.
-""",
-"""\
-<document>
- <table>
- <tgroup cols="2">
- <colspec colwidth="17">
- <colspec colwidth="8">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A simple table
- <entry>
- <paragraph>
- cell 2
- <row>
- <entry>
- <paragraph>
- cell 3
- <entry>
- <paragraph>
- cell 4
- <system_message level="2" type="WARNING">
- <paragraph>
- Blank line required after table at line 6.
- <paragraph>
- No blank line after table.
-"""],
-["""\
-+-----------------+--------+
-| A simple table | cell 2 |
-+-----------------+--------+
-| cell 3 | cell 4 |
-+-----------------+--------+
- Unexpected indent and no blank line after table.
-""",
-"""\
-<document>
- <table>
- <tgroup cols="2">
- <colspec colwidth="17">
- <colspec colwidth="8">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A simple table
- <entry>
- <paragraph>
- cell 2
- <row>
- <entry>
- <paragraph>
- cell 3
- <entry>
- <paragraph>
- cell 4
- <system_message level="3" type="ERROR">
- <paragraph>
- Unexpected indentation at line 6.
- <system_message level="2" type="WARNING">
- <paragraph>
- Blank line required after table at line 6.
- <block_quote>
- <paragraph>
- Unexpected indent and no blank line after table.
-"""],
-["""\
-+--------------+-------------+
-| A bad table. | |
-+--------------+ |
-| Cells must be rectangles. |
-+----------------------------+
-""",
-"""\
-<document>
- <system_message level="3" type="ERROR">
- <paragraph>
- Malformed table at line 1; formatting as a literal block.
- Malformed table; parse incomplete.
- <literal_block>
- +--------------+-------------+
- | A bad table. | |
- +--------------+ |
- | Cells must be rectangles. |
- +----------------------------+
-"""],
-["""\
-+------------------------------+
-| This table contains another. |
-| |
-| +-------------------------+ |
-| | A table within a table. | |
-| +-------------------------+ |
-+------------------------------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="1">
- <colspec colwidth="30">
- <tbody>
- <row>
- <entry>
- <paragraph>
- This table contains another.
- <table>
- <tgroup cols="1">
- <colspec colwidth="25">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A table within a table.
-"""],
-["""\
-+------------------+--------+
-| A simple table | |
-+------------------+--------+
-| with empty cells | |
-+------------------+--------+
-""",
-"""\
-<document>
- <table>
- <tgroup cols="2">
- <colspec colwidth="18">
- <colspec colwidth="8">
- <tbody>
- <row>
- <entry>
- <paragraph>
- A simple table
- <entry>
- <row>
- <entry>
- <paragraph>
- with empty cells
- <entry>
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_targets.py b/docutils/test/test_parsers/test_rst/test_targets.py
deleted file mode 100755
index 1379db420..000000000
--- a/docutils/test/test_parsers/test_rst/test_targets.py
+++ /dev/null
@@ -1,429 +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 states.py.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['targets'] = [
-["""\
-.. _target:
-
-(Internal hyperlink target.)
-""",
-"""\
-<document>
- <target id="target" name="target">
- <paragraph>
- (Internal hyperlink target.)
-"""],
-["""\
-External hyperlink targets:
-
-.. _one-liner: http://structuredtext.sourceforge.net
-
-.. _starts-on-this-line: http://
- structuredtext.
- sourceforge.net
-
-.. _entirely-below:
- http://structuredtext.
- sourceforge.net
-
-.. _not-indirect: uri\_
-""",
-"""\
-<document>
- <paragraph>
- External hyperlink targets:
- <target id="one-liner" name="one-liner" refuri="http://structuredtext.sourceforge.net">
- <target id="starts-on-this-line" name="starts-on-this-line" refuri="http://structuredtext.sourceforge.net">
- <target id="entirely-below" name="entirely-below" refuri="http://structuredtext.sourceforge.net">
- <target id="not-indirect" name="not-indirect" refuri="uri_">
-"""],
-["""\
-Indirect hyperlink targets:
-
-.. _target1: reference_
-
-.. _target2: `phrase-link reference`_
-""",
-"""\
-<document>
- <paragraph>
- Indirect hyperlink targets:
- <target id="target1" name="target1" refname="reference">
- <target id="target2" name="target2" refname="phrase-link reference">
-"""],
-["""\
-.. _target1: Not a proper hyperlink target
-
-.. _target2: Although it ends with an underscore, this is not a phrase-link_
-
-.. _target3: A multi-line verson of something
- ending with an underscore, but not a phrase-link_
-""",
-"""\
-<document>
- <system_message level="2" type="WARNING">
- <paragraph>
- Hyperlink target at line 1 contains whitespace. Perhaps a footnote was intended?
- <literal_block>
- .. _target1: Not a proper hyperlink target
- <system_message level="2" type="WARNING">
- <paragraph>
- Hyperlink target at line 3 contains whitespace. Perhaps a footnote was intended?
- <literal_block>
- .. _target2: Although it ends with an underscore, this is not a phrase-link_
- <system_message level="2" type="WARNING">
- <paragraph>
- Hyperlink target at line 5 contains whitespace. Perhaps a footnote was intended?
- <literal_block>
- .. _target3: A multi-line verson of something
- ending with an underscore, but not a phrase-link_
-"""],
-["""\
-.. __: Not a proper hyperlink target
-
-__ Although it ends with an underscore, this is not a phrase-link_
-
-__ A multi-line verson of something
- ending with an underscore, but not a phrase-link_
-""",
-"""\
-<document>
- <system_message level="2" type="WARNING">
- <paragraph>
- Hyperlink target at line 1 contains whitespace. Perhaps a footnote was intended?
- <literal_block>
- .. __: Not a proper hyperlink target
- <system_message level="2" type="WARNING">
- <paragraph>
- Anonymous hyperlink target at line 3 contains whitespace. Perhaps a footnote was intended?
- <literal_block>
- __ Although it ends with an underscore, this is not a phrase-link_
- <system_message level="2" type="WARNING">
- <paragraph>
- Anonymous hyperlink target at line 5 contains whitespace. Perhaps a footnote was intended?
- <literal_block>
- __ A multi-line verson of something
- ending with an underscore, but not a phrase-link_
-"""],
-["""\
-.. _a long target name:
-
-.. _`a target name: including a colon (quoted)`:
-
-.. _a target name\: including a colon (escaped):
-""",
-"""\
-<document>
- <target id="a-long-target-name" name="a long target name">
- <target id="a-target-name-including-a-colon-quoted" name="a target name: including a colon (quoted)">
- <target id="a-target-name-including-a-colon-escaped" name="a target name: including a colon (escaped)">
-"""],
-["""\
-.. _a very long target name,
- split across lines:
-.. _`and another,
- with backquotes`:
-""",
-"""\
-<document>
- <target id="a-very-long-target-name-split-across-lines" name="a very long target name, split across lines">
- <target id="and-another-with-backquotes" name="and another, with backquotes">
-"""],
-["""\
-External hyperlink:
-
-.. _target: http://www.python.org/
-""",
-"""\
-<document>
- <paragraph>
- External hyperlink:
- <target id="target" name="target" refuri="http://www.python.org/">
-"""],
-["""\
-Duplicate external targets (different URIs):
-
-.. _target: first
-
-.. _target: second
-""",
-"""\
-<document>
- <paragraph>
- Duplicate external targets (different URIs):
- <target dupname="target" id="target" refuri="first">
- <system_message backrefs="id1" level="2" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "target".
- <target dupname="target" id="id1" refuri="second">
-"""],
-["""\
-Duplicate external targets (same URIs):
-
-.. _target: first
-
-.. _target: first
-""",
-"""\
-<document>
- <paragraph>
- Duplicate external targets (same URIs):
- <target dupname="target" id="target" refuri="first">
- <system_message backrefs="id1" level="1" type="INFO">
- <paragraph>
- Duplicate explicit target name: "target".
- <target id="id1" name="target" refuri="first">
-"""],
-["""\
-Duplicate implicit targets.
-
-Title
-=====
-
-Paragraph.
-
-Title
-=====
-
-Paragraph.
-""",
-"""\
-<document>
- <paragraph>
- Duplicate implicit targets.
- <section dupname="title" id="title">
- <title>
- Title
- <paragraph>
- Paragraph.
- <section dupname="title" id="id1">
- <title>
- Title
- <system_message backrefs="id1" level="1" type="INFO">
- <paragraph>
- Duplicate implicit target name: "title".
- <paragraph>
- Paragraph.
-"""],
-["""\
-Duplicate implicit/explicit targets.
-
-Title
-=====
-
-.. _title:
-
-Paragraph.
-""",
-"""\
-<document>
- <paragraph>
- Duplicate implicit/explicit targets.
- <section dupname="title" id="title">
- <title>
- Title
- <system_message backrefs="id1" level="1" type="INFO">
- <paragraph>
- Duplicate implicit target name: "title".
- <target id="id1" name="title">
- <paragraph>
- Paragraph.
-"""],
-["""\
-Duplicate explicit targets.
-
-.. _title:
-
-First.
-
-.. _title:
-
-Second.
-
-.. _title:
-
-Third.
-""",
-"""\
-<document>
- <paragraph>
- Duplicate explicit targets.
- <target dupname="title" id="title">
- <paragraph>
- First.
- <system_message backrefs="id1" level="2" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "title".
- <target dupname="title" id="id1">
- <paragraph>
- Second.
- <system_message backrefs="id2" level="2" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "title".
- <target dupname="title" id="id2">
- <paragraph>
- Third.
-"""],
-["""\
-Duplicate targets:
-
-Target
-======
-
-Implicit section header target.
-
-.. [target] Citation target.
-
-.. [#target] Autonumber-labeled footnote target.
-
-.. _target:
-
-Explicit internal target.
-
-.. _target: Explicit_external_target
-""",
-"""\
-<document>
- <paragraph>
- Duplicate targets:
- <section dupname="target" id="target">
- <title>
- Target
- <paragraph>
- Implicit section header target.
- <citation dupname="target" id="id1">
- <label>
- target
- <system_message backrefs="id1" level="1" type="INFO">
- <paragraph>
- Duplicate implicit target name: "target".
- <paragraph>
- Citation target.
- <footnote auto="1" dupname="target" id="id2">
- <system_message backrefs="id2" level="2" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "target".
- <paragraph>
- Autonumber-labeled footnote target.
- <system_message backrefs="id3" level="2" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "target".
- <target dupname="target" id="id3">
- <paragraph>
- Explicit internal target.
- <system_message backrefs="id4" level="2" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "target".
- <target dupname="target" id="id4" refuri="Explicit_external_target">
-"""],
-]
-
-totest['anonymous_targets'] = [
-["""\
-Anonymous external hyperlink target:
-
-.. __: http://w3c.org/
-""",
-"""\
-<document>
- <paragraph>
- Anonymous external hyperlink target:
- <target anonymous="1" id="id1" refuri="http://w3c.org/">
-"""],
-["""\
-Anonymous external hyperlink target:
-
-__ http://w3c.org/
-""",
-"""\
-<document>
- <paragraph>
- Anonymous external hyperlink target:
- <target anonymous="1" id="id1" refuri="http://w3c.org/">
-"""],
-["""\
-Anonymous indirect hyperlink target:
-
-.. __: reference_
-""",
-"""\
-<document>
- <paragraph>
- Anonymous indirect hyperlink target:
- <target anonymous="1" id="id1" refname="reference">
-"""],
-["""\
-Anonymous indirect hyperlink targets:
-
-__ reference_
-__ `a very long
- reference`_
-""",
-"""\
-<document>
- <paragraph>
- Anonymous indirect hyperlink targets:
- <target anonymous="1" id="id1" refname="reference">
- <target anonymous="1" id="id2" refname="a very long reference">
-"""],
-["""\
-Mixed anonymous & named indirect hyperlink targets:
-
-__ reference_
-.. __: reference_
-__ reference_
-.. _target1: reference_
-no blank line
-
-.. _target2: reference_
-__ reference_
-.. __: reference_
-__ reference_
-no blank line
-""",
-"""\
-<document>
- <paragraph>
- Mixed anonymous & named indirect hyperlink targets:
- <target anonymous="1" id="id1" refname="reference">
- <target anonymous="1" id="id2" refname="reference">
- <target anonymous="1" id="id3" refname="reference">
- <target id="target1" name="target1" refname="reference">
- <system_message level="2" type="WARNING">
- <paragraph>
- Explicit markup ends without a blank line; unexpected unindent at line 7.
- <paragraph>
- no blank line
- <target id="target2" name="target2" refname="reference">
- <target anonymous="1" id="id4" refname="reference">
- <target anonymous="1" id="id5" refname="reference">
- <target anonymous="1" id="id6" refname="reference">
- <system_message level="2" type="WARNING">
- <paragraph>
- Explicit markup ends without a blank line; unexpected unindent at line 13.
- <paragraph>
- no blank line
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_parsers/test_rst/test_transitions.py b/docutils/test/test_parsers/test_rst/test_transitions.py
deleted file mode 100755
index acb9b0ab2..000000000
--- a/docutils/test/test_parsers/test_rst/test_transitions.py
+++ /dev/null
@@ -1,144 +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 transition markers.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.ParserTestSuite()
- s.generateTests(totest)
- return s
-
-totest = {}
-
-# See DocutilsTestSupport.ParserTestSuite.generateTests for a
-# description of the 'totest' data structure.
-totest['transitions'] = [
-["""\
-Test transition markers.
-
---------
-
-Paragraph
-""",
-"""\
-<document>
- <paragraph>
- Test transition markers.
- <transition>
- <paragraph>
- Paragraph
-"""],
-["""\
-Section 1
-=========
-First text division of section 1.
-
---------
-
-Second text division of section 1.
-
-Section 2
----------
-Paragraph 2 in section 2.
-""",
-"""\
-<document>
- <section id="section-1" name="section 1">
- <title>
- Section 1
- <paragraph>
- First text division of section 1.
- <transition>
- <paragraph>
- Second text division of section 1.
- <section id="section-2" name="section 2">
- <title>
- Section 2
- <paragraph>
- Paragraph 2 in section 2.
-"""],
-["""\
---------
-
-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>
- <system_message level="3" type="ERROR">
- <paragraph>
- Document or section may not begin with a transition (line 1).
- <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" type="ERROR">
- <paragraph>
- At least one body element must separate transitions; adjacent transitions at line 10.
- <transition>
- <system_message level="3" type="ERROR">
- <paragraph>
- At least one body element must separate transitions; adjacent transitions at line 12.
- <transition>
- <paragraph>
- The DTD also specifies that a section or document
- may not end with a transition.
- <transition>
- <system_message level="3" type="ERROR">
- <paragraph>
- Document or section may not end with a transition (line 17).
-"""],
-["""\
-Test unexpected transition markers.
-
- Block quote.
-
- --------
-
- Paragraph.
-""",
-"""\
-<document>
- <paragraph>
- Test unexpected transition markers.
- <block_quote>
- <paragraph>
- Block quote.
- <system_message level="4" type="SEVERE">
- <paragraph>
- Unexpected section title or transition at line 5.
- <literal_block>
- --------
- <paragraph>
- Paragraph.
-"""],
-]
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_statemachine.py b/docutils/test/test_statemachine.py
deleted file mode 100755
index a73a17197..000000000
--- a/docutils/test/test_statemachine.py
+++ /dev/null
@@ -1,296 +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.
-
-Test module for statemachine.py.
-"""
-
-import unittest, sys, re
-from DocutilsTestSupport import statemachine
-try:
- import mypdb as pdb
-except:
- import pdb
-pdb.tracenow = 0
-
-debug = 0
-testtext = statemachine.string2lines("""\
-First paragraph.
-
-- This is a bullet list. First list item.
- Second line of first para.
-
- Second para.
-
- block quote
-
-- Second list item. Example::
-
- a
- literal
- block
-
-Last paragraph.""")
-expected = ('StateMachine1 text1 blank1 bullet1 knownindent1 '
- 'StateMachine2 text2 text2 blank2 text2 blank2 indent2 '
- 'StateMachine3 text3 blank3 finished3 finished2 '
- 'bullet1 knownindent1 '
- 'StateMachine2 text2 blank2 literalblock2(4) finished2 '
- 'text1 finished1').split()
-para1 = testtext[:2]
-item1 = [line[2:] for line in testtext[2:9]]
-item2 = [line[2:] for line in testtext[9:-1]]
-lbindent = 6
-literalblock = [line[lbindent:] for line in testtext[11:-1]]
-para2 = testtext[-1]
-
-
-class MockState(statemachine.StateWS):
-
- patterns = {'bullet': re.compile(r'- '),
- 'text': ''}
- initialtransitions = ['bullet', ['text']]
- levelholder = [0]
-
- def bof(self, context):
- self.levelholder[0] += 1
- self.level = self.levelholder[0]
- if self.debug: print >>sys.stderr, 'StateMachine%s' % self.level
- return [], ['StateMachine%s' % self.level]
-
- def blank(self, match, context, nextstate):
- result = ['blank%s' % self.level]
- if self.debug: print >>sys.stderr, 'blank%s' % self.level
- if context and context[-1] and context[-1][-2:] == '::':
- result.extend(self.literalblock())
- return [], None, result
-
- def indent(self, match, context, nextstate):
- if self.debug: print >>sys.stderr, 'indent%s' % self.level
- context, nextstate, result = statemachine.StateWS.indent(
- self, match, context, nextstate)
- return context, nextstate, ['indent%s' % self.level] + result
-
- def knownindent(self, match, context, nextstate):
- if self.debug: print >>sys.stderr, 'knownindent%s' % self.level
- context, nextstate, result = statemachine.StateWS.knownindent(
- self, match, context, nextstate)
- return context, nextstate, ['knownindent%s' % self.level] + result
-
- def bullet(self, match, context, nextstate):
- if self.debug: print >>sys.stderr, 'bullet%s' % self.level
- context, nextstate, result \
- = self.knownindent(match, context, nextstate)
- return [], nextstate, ['bullet%s' % self.level] + result
-
- def text(self, match, context, nextstate):
- if self.debug: print >>sys.stderr, 'text%s' % self.level
- return [match.string], nextstate, ['text%s' % self.level]
-
- def literalblock(self):
- indented, indent, offset, good = self.statemachine.getindented()
- if self.debug: print >>sys.stderr, 'literalblock%s(%s)' % (self.level,
- indent)
- return ['literalblock%s(%s)' % (self.level, indent)]
-
- def eof(self, context):
- self.levelholder[0] -= 1
- if self.debug: print >>sys.stderr, 'finished%s' % self.level
- return ['finished%s' % self.level]
-
-
-class EmptySMTests(unittest.TestCase):
-
- def setUp(self):
- self.sm = statemachine.StateMachine(
- stateclasses=[], initialstate='State')
- self.sm.debug = debug
-
- def test_addstate(self):
- self.sm.addstate(statemachine.State)
- self.assert_(len(self.sm.states) == 1)
- self.assertRaises(statemachine.DuplicateStateError, self.sm.addstate,
- statemachine.State)
- self.sm.addstate(statemachine.StateWS)
- self.assert_(len(self.sm.states) == 2)
-
- def test_addstates(self):
- self.sm.addstates((statemachine.State, statemachine.StateWS))
- self.assertEqual(len(self.sm.states), 2)
-
- def test_getstate(self):
- self.assertRaises(statemachine.UnknownStateError, self.sm.getstate)
- self.sm.addstates((statemachine.State, statemachine.StateWS))
- self.assertRaises(statemachine.UnknownStateError, self.sm.getstate,
- 'unknownState')
- self.assert_(isinstance(self.sm.getstate('State'),
- statemachine.State))
- self.assert_(isinstance(self.sm.getstate('StateWS'),
- statemachine.State))
- self.assertEqual(self.sm.currentstate, 'StateWS')
-
-
-class EmptySMWSTests(EmptySMTests):
-
- def setUp(self):
- self.sm = statemachine.StateMachineWS(
- stateclasses=[], initialstate='State')
- self.sm.debug = debug
-
-
-class SMWSTests(unittest.TestCase):
-
- def setUp(self):
- self.sm = statemachine.StateMachineWS([MockState], 'MockState',
- debug=debug)
- self.sm.debug = debug
- self.sm.states['MockState'].levelholder[0] = 0
-
- def tearDown(self):
- self.sm.unlink()
-
- def test___init__(self):
- self.assertEquals(self.sm.states.keys(), ['MockState'])
- self.assertEquals(len(self.sm.states['MockState'].transitions), 2)
-
- def test_getindented(self):
- self.sm.inputlines = testtext
- self.sm.lineoffset = -1
- self.sm.nextline(3)
- indented, offset, good = self.sm.getknownindented(2)
- self.assertEquals(indented, item1)
- self.assertEquals(offset, len(para1))
- self.failUnless(good)
- self.sm.nextline()
- indented, offset, good = self.sm.getknownindented(2)
- self.assertEquals(indented, item2)
- self.assertEquals(offset, len(para1) + len(item1))
- self.failUnless(good)
- self.sm.previousline(3)
- if self.sm.debug:
- print '\ntest_getindented: self.sm.line:\n', self.sm.line
- indented, indent, offset, good = self.sm.getindented()
- if self.sm.debug:
- print '\ntest_getindented: indented:\n', indented
- self.assertEquals(indent, lbindent)
- self.assertEquals(indented, literalblock)
- self.assertEquals(offset, (len(para1) + len(item1) + len(item2)
- - len(literalblock)))
- self.failUnless(good)
-
- def test_gettextblock(self):
- self.sm.inputlines = testtext
- self.sm.lineoffset = -1
- self.sm.nextline()
- textblock = self.sm.gettextblock()
- self.assertEquals(textblock, testtext[:1])
- self.sm.nextline(2)
- textblock = self.sm.gettextblock()
- self.assertEquals(textblock, testtext[2:4])
-
- def test_getunindented(self):
- self.sm.inputlines = testtext
- self.sm.lineoffset = -1
- self.sm.nextline()
- textblock = self.sm.getunindented()
- self.assertEquals(textblock, testtext[:1])
- self.sm.nextline()
- self.assertRaises(statemachine.UnexpectedIndentationError,
- self.sm.getunindented)
-
- def test_run(self):
- self.assertEquals(self.sm.run(testtext), expected)
-
-
-class EmptyClass:
- pass
-
-
-class EmptyStateTests(unittest.TestCase):
-
- def setUp(self):
- self.state = statemachine.State(EmptyClass(), debug=debug)
- self.state.patterns = {'nop': 'dummy',
- 'nop2': 'dummy',
- 'nop3': 'dummy',
- 'bogus': 'dummy'}
- self.state.nop2 = self.state.nop3 = self.state.nop
-
- def test_addtransitions(self):
- self.assertEquals(len(self.state.transitions), 0)
- self.state.addtransitions(['None'], {'None': None})
- self.assertEquals(len(self.state.transitions), 1)
- self.assertRaises(statemachine.UnknownTransitionError,
- self.state.addtransitions, ['bogus'], {})
- self.assertRaises(statemachine.DuplicateTransitionError,
- self.state.addtransitions, ['None'], {'None': None})
-
- def test_addtransition(self):
- self.assertEquals(len(self.state.transitions), 0)
- self.state.addtransition('None', None)
- self.assertEquals(len(self.state.transitions), 1)
- self.assertRaises(statemachine.DuplicateTransitionError,
- self.state.addtransition, 'None', None)
-
- def test_removetransition(self):
- self.assertEquals(len(self.state.transitions), 0)
- self.state.addtransition('None', None)
- self.assertEquals(len(self.state.transitions), 1)
- self.state.removetransition('None')
- self.assertEquals(len(self.state.transitions), 0)
- self.assertRaises(statemachine.UnknownTransitionError,
- self.state.removetransition, 'None')
-
- def test_maketransition(self):
- dummy = re.compile('dummy')
- self.assertEquals(self.state.maketransition('nop', 'bogus'),
- (dummy, self.state.nop, 'bogus'))
- self.assertEquals(self.state.maketransition('nop'),
- (dummy, self.state.nop,
- self.state.__class__.__name__))
- self.assertRaises(statemachine.TransitionPatternNotFound,
- self.state.maketransition, 'None')
- self.assertRaises(statemachine.TransitionMethodNotFound,
- self.state.maketransition, 'bogus')
-
- def test_maketransitions(self):
- dummy = re.compile('dummy')
- self.assertEquals(self.state.maketransitions(('nop', ['nop2'],
- ('nop3', 'bogus'))),
- (['nop', 'nop2', 'nop3'],
- {'nop': (dummy, self.state.nop,
- self.state.__class__.__name__),
- 'nop2': (dummy, self.state.nop2,
- self.state.__class__.__name__),
- 'nop3': (dummy, self.state.nop3, 'bogus')}))
-
-
-class MiscTests(unittest.TestCase):
-
- s2l_string = "hello\tthere\thow are\tyou?\n\tI'm fine\tthanks.\n"
- s2l_expected = ['hello there how are you?',
- " I'm fine thanks."]
- indented_string = """\
- a
- literal
- block"""
-
- def test_string2lines(self):
- self.assertEquals(statemachine.string2lines(self.s2l_string),
- self.s2l_expected)
-
- def test_extractindented(self):
- block = statemachine.string2lines(self.indented_string)
- self.assertEquals(statemachine.extractindented(block),
- ([s[6:] for s in block], 6, 1))
- self.assertEquals(statemachine.extractindented(self.s2l_expected),
- ([], 0, 0))
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/docutils/test/test_transforms/__init__.py b/docutils/test/test_transforms/__init__.py
deleted file mode 100644
index 027d2f3bc..000000000
--- a/docutils/test/test_transforms/__init__.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import os, os.path, 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)
diff --git a/docutils/test/test_transforms/test_contents.py b/docutils/test/test_transforms/test_contents.py
deleted file mode 100755
index 05a159796..000000000
--- a/docutils/test/test_transforms/test_contents.py
+++ /dev/null
@@ -1,262 +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.Contents.
-"""
-
-from __init__ import DocutilsTestSupport
-from docutils.transforms.universal import LastReaderPending
-from docutils.parsers.rst import Parser
-
-
-def suite():
- parser = Parser()
- s = DocutilsTestSupport.TransformTestSuite(parser)
- s.generateTests(totest)
- return s
-
-totest = {}
-
-totest['tables_of_contents'] = ((LastReaderPending,), [
-["""\
-.. contents::
-
-Title 1
-=======
-Paragraph 1.
-
-Title 2
--------
-Paragraph 2.
-
-Title 3
-```````
-Paragraph 3.
-
-Title 4
--------
-Paragraph 4.
-""",
-"""\
-<document>
- <topic class="contents">
- <title>
- Contents
- <bullet_list>
- <list_item id="id1">
- <paragraph>
- <reference refid="title-1">
- Title 1
- <bullet_list>
- <list_item id="id2">
- <paragraph>
- <reference refid="title-2">
- Title 2
- <bullet_list>
- <list_item id="id3">
- <paragraph>
- <reference refid="title-3">
- Title 3
- <list_item id="id4">
- <paragraph>
- <reference 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>
- <topic class="contents">
- <title>
- Table of Contents
- <bullet_list>
- <list_item id="id1">
- <paragraph>
- <reference refid="title-1">
- Title 1
- <bullet_list>
- <list_item id="id2">
- <paragraph>
- <reference 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::
- :depth: 2
-
-Title 1
-=======
-Paragraph 1.
-
-Title 2
--------
-Paragraph 2.
-
-Title 3
-```````
-Paragraph 3.
-
-Title 4
--------
-Paragraph 4.
-""",
-"""\
-<document>
- <topic class="contents">
- <title>
- Contents
- <bullet_list>
- <list_item id="id1">
- <paragraph>
- <reference refid="title-1">
- Title 1
- <bullet_list>
- <list_item id="id2">
- <paragraph>
- <reference refid="title-2">
- Title 2
- <list_item id="id3">
- <paragraph>
- <reference 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>
- <section id="title-1" name="title 1">
- <title>
- Title 1
- <topic class="contents">
- <bullet_list>
- <list_item id="id1">
- <paragraph>
- <reference refid="title-2">
- Title 2
- <bullet_list>
- <list_item id="id2">
- <paragraph>
- <reference refid="title-3">
- Title 3
- <list_item id="id3">
- <paragraph>
- <reference 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::
-
-Degenerate case, no table of contents generated.
-""",
-"""\
-<document>
- <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 d5dd4b873..000000000
--- a/docutils/test/test_transforms/test_docinfo.py
+++ /dev/null
@@ -1,326 +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>
- <docinfo>
- <author>
- Me
- <version>
- 1
- <date>
- 2001-08-11
- <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>
- Bibliographic element extraction.
- <field_list>
- <field>
- <field_name>
- Parameter
- <field_argument>
- i
- <field_body>
- <paragraph>
- integer
-"""],
-["""\
-.. Bibliographic element extraction.
-
-:Abstract: Abstract 1.
-:Author: Me
-:Contact: me@my.org
-:Version: 1
-:Abstract: Abstract 2 (should generate a warning).
-:Date: 2001-08-11
-:Parameter i: integer
-""",
-"""\
-<document>
- <docinfo>
- <author>
- Me
- <contact>
- <reference refuri="mailto:me@my.org">
- me@my.org
- <version>
- 1
- <date>
- 2001-08-11
- <topic class="abstract">
- <title>
- Abstract
- <paragraph>
- Abstract 1.
- <comment>
- Bibliographic element extraction.
- <field_list>
- <field>
- <field_name>
- Abstract
- <field_body>
- <paragraph>
- Abstract 2 (should generate a warning).
- <system_message level="2" type="WARNING">
- <paragraph>
- There can only be one abstract.
- <field>
- <field_name>
- Parameter
- <field_argument>
- i
- <field_body>
- <paragraph>
- integer
-"""],
-["""\
-:Author: - must be a paragraph
-:Status: a *simple* paragraph
-:Date: But only one
-
- paragraph.
-:Version:
-
-.. and not empty either
-""",
-"""\
-<document>
- <docinfo>
- <status>
- a \n\
- <emphasis>
- simple
- paragraph
- <field_list>
- <field>
- <field_name>
- Author
- <field_body>
- <bullet_list bullet="-">
- <list_item>
- <paragraph>
- must be a paragraph
- <system_message level="2" type="WARNING">
- <paragraph>
- Cannot extract bibliographic field "Author" containing anything other than a single paragraph.
- <field>
- <field_name>
- Date
- <field_body>
- <paragraph>
- But only one
- <paragraph>
- paragraph.
- <system_message level="2" type="WARNING">
- <paragraph>
- Cannot extract compound bibliographic field "Date".
- <field>
- <field_name>
- Version
- <field_body>
- <system_message level="2" type="WARNING">
- <paragraph>
- Cannot extract empty bibliographic field "Version".
- <comment>
- and not empty either
-"""],
-["""\
-:Authors: Me, Myself, **I**
-:Authors: PacMan; Ms. PacMan; PacMan, Jr.
-:Authors:
- Here
-
- There
-
- *Everywhere*
-:Authors: - First
- - Second
- - Third
-""",
-"""\
-<document>
- <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:
-
-:Authors: 1. One
- 2. Two
-
-:Authors:
- -
- -
-
-:Authors:
- - One
-
- Two
-
-:Authors:
- - One
-
- Two
-""",
-"""\
-<document>
- <field_list>
- <field>
- <field_name>
- Authors
- <field_body>
- <system_message level="2" 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" 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" 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" 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" 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>
- <docinfo>
- <status>
- test_docinfo.py
- <date>
- %s
- <comment>
- 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 842906945..000000000
--- a/docutils/test/test_transforms/test_doctitle.py
+++ /dev/null
@@ -1,174 +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">
- <title>
- Title
- <comment>
- test title promotion
- <paragraph>
- Paragraph.
-"""],
-["""\
-Title
-=====
-Paragraph (no blank line).
-""",
-"""\
-<document id="title" name="title">
- <title>
- Title
- <paragraph>
- Paragraph (no blank line).
-"""],
-["""\
-Paragraph.
-
-Title
-=====
-
-Paragraph.
-""",
-"""\
-<document>
- <paragraph>
- Paragraph.
- <section id="title" name="title">
- <title>
- Title
- <paragraph>
- Paragraph.
-"""],
-["""\
-Title
-=====
-
-Subtitle
---------
-
-Test title & subtitle.
-""",
-"""\
-<document id="title" name="title">
- <title>
- Title
- <subtitle id="subtitle" name="subtitle">
- Subtitle
- <paragraph>
- Test title & subtitle.
-"""],
-["""\
-Title
-====
-
-Test short underline.
-""",
-"""\
-<document id="title" name="title">
- <title>
- Title
- <system_message level="1" type="INFO">
- <paragraph>
- Title underline too short at line 2.
- <literal_block>
- 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">
- <title>
- Long Title
- <system_message level="1" type="INFO">
- <paragraph>
- Title overline too short at line 1.
- <literal_block>
- =======
- 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">
- <title>
- Title 1
- <comment>
- 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_final_checks.py b/docutils/test/test_transforms/test_final_checks.py
deleted file mode 100755
index c74919c56..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>
- <paragraph>
- Unknown
- <problematic id="id2" refid="id1">
- reference_
- .
- <system_message backrefs="id2" id="id1" level="3" 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 9a3c09aa5..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>
- <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>
- <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>
- <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>
- <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>
- <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" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "five".
- <paragraph>
- Auto-numbered footnote 5 again (duplicate).
- <system_message backrefs="id11" id="id10" level="3" 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>
- <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>
- <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>
- <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" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "five".
- <paragraph>
- Auto-numbered footnote 5 again (duplicate).
- <system_message backrefs="id15" id="id14" level="3" 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>
- <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>
- <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 811b2dcfe..000000000
--- a/docutils/test/test_transforms/test_hyperlinks.py
+++ /dev/null
@@ -1,440 +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 Hyperlinks
-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.
-totest['exhaustive_hyperlinks'] = ((Hyperlinks,), [
-["""\
-direct_ external
-
-.. _direct: http://direct
-""",
-"""\
-<document>
- <paragraph>
- <reference refuri="http://direct">
- direct
- external
- <target id="direct" name="direct" refuri="http://direct">
-"""],
-["""\
-indirect_ external
-
-.. _indirect: xtarget_
-.. _xtarget: http://indirect
-""",
-"""\
-<document>
- <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>
- <target id="direct" name="direct">
- <paragraph>
- <reference refid="direct">
- direct
- internal
-"""],
-["""\
-.. _ztarget:
-
-indirect_ internal
-
-.. _indirect2: ztarget_
-.. _indirect: indirect2_
-""",
-"""\
-<document>
- <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>
- <section id="implicit" name="implicit">
- <title>
- Implicit
- <paragraph>
- <reference refid="implicit">
- indirect
- internal
- <target id="indirect" name="indirect" refid="implicit">
-"""],
-["""\
-Implicit
---------
-
-Duplicate implicit targets.
-
-Implicit
---------
-
-indirect_ internal
-
-.. _indirect: implicit_
-""",
-"""\
-<document>
- <section dupname="implicit" id="implicit">
- <title>
- Implicit
- <paragraph>
- Duplicate implicit targets.
- <section dupname="implicit" id="id1">
- <title>
- Implicit
- <system_message backrefs="id1" level="1" 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="2" type="WARNING">
- <paragraph>
- Indirect hyperlink target "indirect" (id="indirect") refers to target "implicit", which does not exist.
-"""],
-["""\
-`direct external`__
-
-__ http://direct
-""",
-"""\
-<document>
- <paragraph>
- <reference anonymous="1" refuri="http://direct">
- direct external
- <target anonymous="1" id="id1" refuri="http://direct">
-"""],
-["""\
-`indirect external`__
-
-__ xtarget_
-.. _xtarget: http://indirect
-""",
-"""\
-<document>
- <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>
- <target anonymous="1" id="id1">
- <paragraph>
- <reference anonymous="1" refid="id1">
- direct internal
-"""],
-["""\
-.. _ztarget:
-
-`indirect internal`__
-
-__ ztarget_
-""",
-"""\
-<document>
- <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>
- <target dupname="ztarget" id="ztarget">
- <paragraph>
- First
- <system_message backrefs="id1" level="2" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "ztarget".
- <target dupname="ztarget" id="id1">
- <paragraph>
- Second
- <paragraph>
- <reference anonymous="1" refid="id1">
- indirect internal
- <target anonymous="1" id="id2" refid="id1">
-"""],
-])
-
-totest['hyperlinks'] = ((Hyperlinks,), [
-["""\
-.. _internal hyperlink:
-
-This paragraph referenced.
-
-By this `internal hyperlink`_ referemce.
-""",
-"""\
-<document>
- <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>
- <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>
- <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>
- <target id="external-hyperlink" name="external hyperlink" refuri="http://uri">
- <target id="indirect-target" name="indirect target" refuri="http://uri">
- <system_message level="1" 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>
- <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>
- <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>
- <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>
- <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>
- <paragraph>
- Duplicate external \n\
- <reference refname="target">
- target
- 's (different URIs):
- <target dupname="target" id="target" refuri="first">
- <system_message backrefs="id1" level="2" 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>
- <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" type="ERROR">
- <paragraph>
- Anonymous hyperlink mismatch: 3 references but 1 targets.
-"""],
-])
-
-
-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 6751c3ecd..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
-doctree by the test framework.)
-""",
-"""\
-<document>
- <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
- doctree by the test framework.)
- <section class="system-messages">
- <title>
- Docutils System Messages
- <system_message backrefs="id2" id="id1" level="3" 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_substitutions.py b/docutils/test/test_transforms/test_substitutions.py
deleted file mode 100755
index c02dd0218..000000000
--- a/docutils/test/test_transforms/test_substitutions.py
+++ /dev/null
@@ -1,60 +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>
- <paragraph>
- The
- <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>
- <paragraph>
- Here's an
- <problematic id="id2" refid="id1">
- |unknown|
- substitution.
- <system_message backrefs="id2" id="id1" level="3" type="ERROR">
- <paragraph>
- Undefined substitution referenced: "unknown".
-"""],
-])
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
diff --git a/docutils/test/test_utils.py b/docutils/test/test_utils.py
deleted file mode 100755
index 29c926f56..000000000
--- a/docutils/test/test_utils.py
+++ /dev/null
@@ -1,324 +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.
-
-Test module for utils.py.
-"""
-
-import unittest, StringIO, sys
-from DocutilsTestSupport import utils, nodes
-try:
- import mypdb as pdb
-except:
- import pdb
-pdb.tracenow = 0
-
-
-class ReporterTests(unittest.TestCase):
-
- stream = StringIO.StringIO()
- reporter = utils.Reporter(2, 4, stream, 1)
-
- def setUp(self):
- self.stream.seek(0)
- self.stream.truncate()
-
- def test_level0(self):
- sw = self.reporter.system_message(0, 'debug output')
- self.assertEquals(sw.pformat(), """\
-<system_message level="0" type="DEBUG">
- <paragraph>
- debug output
-""")
- self.assertEquals(self.stream.getvalue(),
- 'Reporter: DEBUG (0) debug output\n')
-
- def test_level1(self):
- sw = self.reporter.system_message(1, 'a little reminder')
- self.assertEquals(sw.pformat(), """\
-<system_message level="1" type="INFO">
- <paragraph>
- a little reminder
-""")
- self.assertEquals(self.stream.getvalue(), '')
-
- def test_level2(self):
- sw = self.reporter.system_message(2, 'a warning')
- self.assertEquals(sw.pformat(), """\
-<system_message level="2" type="WARNING">
- <paragraph>
- a warning
-""")
- self.assertEquals(self.stream.getvalue(),
- 'Reporter: WARNING (2) a warning\n')
-
- def test_level3(self):
- sw = self.reporter.system_message(3, 'an error')
- self.assertEquals(sw.pformat(), """\
-<system_message level="3" type="ERROR">
- <paragraph>
- an error
-""")
- self.assertEquals(self.stream.getvalue(),
- 'Reporter: ERROR (3) an error\n')
-
- def test_level4(self):
- self.assertRaises(utils.SystemMessage, self.reporter.system_message, 4,
- 'a severe error, raises an exception')
- self.assertEquals(self.stream.getvalue(), 'Reporter: SEVERE (4) '
- 'a severe error, raises an exception\n')
-
-
-class QuietReporterTests(unittest.TestCase):
-
- stream = StringIO.StringIO()
- reporter = utils.Reporter(5, 5, stream, 0)
-
- def setUp(self):
- self.stream.seek(0)
- self.stream.truncate()
-
- def test_debug(self):
- sw = self.reporter.debug('a debug message')
- self.assertEquals(sw.pformat(), """\
-<system_message level="0" type="DEBUG">
- <paragraph>
- a debug message
-""")
- self.assertEquals(self.stream.getvalue(), '')
-
- def test_info(self):
- sw = self.reporter.info('an informational message')
- self.assertEquals(sw.pformat(), """\
-<system_message level="1" type="INFO">
- <paragraph>
- an informational message
-""")
- self.assertEquals(self.stream.getvalue(), '')
-
- def test_warning(self):
- sw = self.reporter.warning('a warning')
- self.assertEquals(sw.pformat(), """\
-<system_message level="2" type="WARNING">
- <paragraph>
- a warning
-""")
- self.assertEquals(self.stream.getvalue(), '')
-
- def test_error(self):
- sw = self.reporter.error('an error')
- self.assertEquals(sw.pformat(), """\
-<system_message level="3" type="ERROR">
- <paragraph>
- an error
-""")
- self.assertEquals(self.stream.getvalue(), '')
-
- def test_severe(self):
- sw = self.reporter.severe('a severe error')
- self.assertEquals(sw.pformat(), """\
-<system_message level="4" type="SEVERE">
- <paragraph>
- a severe error
-""")
- self.assertEquals(self.stream.getvalue(), '')
-
-
-class ReporterCategoryTests(unittest.TestCase):
-
- stream = StringIO.StringIO()
-
- def setUp(self):
- self.stream.seek(0)
- self.stream.truncate()
- self.reporter = utils.Reporter(2, 4, self.stream, 1)
- self.reporter.setconditions('lemon', 1, 3, self.stream, 0)
-
- def test_getset(self):
- self.reporter.setconditions('test', 5, 5, None, 0)
- self.assertEquals(self.reporter.getconditions('other').astuple(),
- (1, 2, 4, self.stream))
- self.assertEquals(self.reporter.getconditions('test').astuple(),
- (0, 5, 5, sys.stderr))
- self.assertEquals(self.reporter.getconditions('test.dummy').astuple(),
- (0, 5, 5, sys.stderr))
- self.reporter.setconditions('test.dummy.spam', 1, 2, self.stream, 1)
- self.assertEquals(
- self.reporter.getconditions('test.dummy.spam').astuple(),
- (1, 1, 2, self.stream))
- self.assertEquals(self.reporter.getconditions('test.dummy').astuple(),
- (0, 5, 5, sys.stderr))
- self.assertEquals(
- self.reporter.getconditions('test.dummy.spam.eggs').astuple(),
- (1, 1, 2, self.stream))
- self.reporter.unsetconditions('test.dummy.spam')
- self.assertEquals(
- self.reporter.getconditions('test.dummy.spam.eggs').astuple(),
- (0, 5, 5, sys.stderr))
-
- def test_debug(self):
- sw = self.reporter.debug('debug output', category='lemon.curry')
- self.assertEquals(self.stream.getvalue(), '')
- sw = self.reporter.debug('debug output')
- self.assertEquals(self.stream.getvalue(),
- 'Reporter: DEBUG (0) debug output\n')
-
- def test_info(self):
- sw = self.reporter.info('some info')
- self.assertEquals(self.stream.getvalue(), '')
- sw = self.reporter.info('some info', category='lemon.curry')
- self.assertEquals(
- self.stream.getvalue(),
- 'Reporter "lemon.curry": INFO (1) some info\n')
-
- def test_warning(self):
- sw = self.reporter.warning('a warning')
- self.assertEquals(self.stream.getvalue(),
- 'Reporter: WARNING (2) a warning\n')
- sw = self.reporter.warning('a warning', category='lemon.curry')
- self.assertEquals(self.stream.getvalue(), """\
-Reporter: WARNING (2) a warning
-Reporter "lemon.curry": WARNING (2) a warning
-""")
-
- def test_error(self):
- sw = self.reporter.error('an error')
- self.assertEquals(self.stream.getvalue(),
- 'Reporter: ERROR (3) an error\n')
- self.assertRaises(utils.SystemMessage, self.reporter.error,
- 'an error', category='lemon.curry')
- self.assertEquals(self.stream.getvalue(), """\
-Reporter: ERROR (3) an error
-Reporter "lemon.curry": ERROR (3) an error
-""")
-
- def test_severe(self):
- self.assertRaises(utils.SystemMessage, self.reporter.severe,
- 'a severe error')
- self.assertEquals(self.stream.getvalue(),
- 'Reporter: SEVERE (4) a severe error\n')
- self.assertRaises(utils.SystemMessage, self.reporter.severe,
- 'a severe error', category='lemon.curry')
- self.assertEquals(self.stream.getvalue(), """\
-Reporter: SEVERE (4) a severe error
-Reporter "lemon.curry": SEVERE (4) a severe error
-""")
-
-
-class NameValueTests(unittest.TestCase):
-
- def test_extract_name_value(self):
- self.assertRaises(utils.NameValueError, utils.extract_name_value,
- 'hello')
- self.assertRaises(utils.NameValueError, utils.extract_name_value,
- 'hello')
- self.assertRaises(utils.NameValueError, utils.extract_name_value,
- '=hello')
- self.assertRaises(utils.NameValueError, utils.extract_name_value,
- 'hello=')
- self.assertRaises(utils.NameValueError, utils.extract_name_value,
- 'hello="')
- self.assertRaises(utils.NameValueError, utils.extract_name_value,
- 'hello="something')
- self.assertRaises(utils.NameValueError, utils.extract_name_value,
- 'hello="something"else')
- output = utils.extract_name_value(
- """att1=val1 att2=val2 att3="value number '3'" att4=val4""")
- self.assertEquals(output, [('att1', 'val1'), ('att2', 'val2'),
- ('att3', "value number '3'"),
- ('att4', 'val4')])
-
-
-class ExtensionAttributeTests(unittest.TestCase):
-
- attributespec = {'a': int, 'bbb': float, 'cdef': (lambda x: x),
- 'empty': (lambda x: x)}
-
- def test_assemble_attribute_dict(self):
- input = utils.extract_name_value('a=1 bbb=2.0 cdef=hol%s' % chr(224))
- self.assertEquals(
- utils.assemble_attribute_dict(input, self.attributespec),
- {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224))})
- input = utils.extract_name_value('a=1 b=2.0 c=hol%s' % chr(224))
- self.assertRaises(KeyError, utils.assemble_attribute_dict,
- input, self.attributespec)
- input = utils.extract_name_value('a=1 bbb=two cdef=hol%s' % chr(224))
- self.assertRaises(ValueError, utils.assemble_attribute_dict,
- input, self.attributespec)
-
- def test_extract_extension_attributes(self):
- field_list = nodes.field_list()
- field_list += nodes.field(
- '', nodes.field_name('', 'a'),
- nodes.field_body('', nodes.paragraph('', '1')))
- field_list += nodes.field(
- '', nodes.field_name('', 'bbb'),
- nodes.field_body('', nodes.paragraph('', '2.0')))
- field_list += nodes.field(
- '', nodes.field_name('', 'cdef'),
- nodes.field_body('', nodes.paragraph('', 'hol%s' % chr(224))))
- field_list += nodes.field(
- '', nodes.field_name('', 'empty'), nodes.field_body())
- self.assertEquals(
- utils.extract_extension_attributes(field_list,
- self.attributespec),
- {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224)),
- 'empty': None})
- self.assertRaises(KeyError, utils.extract_extension_attributes,
- field_list, {})
- field_list += nodes.field(
- '', nodes.field_name('', 'cdef'),
- nodes.field_body('', nodes.paragraph('', 'one'),
- nodes.paragraph('', 'two')))
- self.assertRaises(utils.BadAttributeDataError,
- utils.extract_extension_attributes,
- field_list, self.attributespec)
- field_list[-1] = nodes.field(
- '', nodes.field_name('', 'cdef'),
- nodes.field_argument('', 'bad'),
- nodes.field_body('', nodes.paragraph('', 'no arguments')))
- self.assertRaises(utils.BadAttributeError,
- utils.extract_extension_attributes,
- field_list, self.attributespec)
- field_list[-1] = nodes.field(
- '', nodes.field_name('', 'cdef'),
- nodes.field_body('', nodes.paragraph('', 'duplicate')))
- self.assertRaises(utils.DuplicateAttributeError,
- utils.extract_extension_attributes,
- field_list, self.attributespec)
- field_list[-2] = nodes.field(
- '', nodes.field_name('', 'unkown'),
- nodes.field_body('', nodes.paragraph('', 'unknown')))
- self.assertRaises(KeyError, utils.extract_extension_attributes,
- field_list, self.attributespec)
-
-
-class MiscFunctionTests(unittest.TestCase):
-
- names = [('a', 'a'), ('A', 'a'), ('A a A', 'a a a'),
- ('A a A a', 'a a a a'),
- (' AaA\n\r\naAa\tAaA\t\t', 'aaa aaa aaa')]
-
- def test_normname(self):
- for input, output in self.names:
- normed = utils.normname(input)
- self.assertEquals(normed, output)
-
- ids = [('a', 'a'), ('A', 'a'), ('', ''), ('a b \n c', 'a-b-c'),
- ('a.b.c', 'a-b-c'), (' - a - b - c - ', 'a-b-c'), (' - ', ''),
- (u'\u2020\u2066', ''), (u'a \xa7 b \u2020 c', 'a-b-c'),
- ('1', ''), ('1abc', 'abc')]
-
- def test_id(self):
- for input, output in self.ids:
- normed = utils.id(input)
- self.assertEquals(normed, output)
-
-
-if __name__ == '__main__':
- unittest.main()