diff options
| author | (no author) <(no author)@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2003-07-02 17:51:01 +0000 |
|---|---|---|
| committer | (no author) <(no author)@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2003-07-02 17:51:01 +0000 |
| commit | edf2f3bec1de42965e347eb808f8604151c35bdb (patch) | |
| tree | 783ec29ed403599a0717019ac974ed2fd7366207 /docutils/test | |
| parent | 97e20d03d7a4f773f24b082b76a34411acc1fefd (diff) | |
| download | docutils-ax.tar.gz | |
This commit was manufactured by cvs2svn to create branch 'ax'.ax
git-svn-id: http://svn.code.sf.net/p/docutils/code/branches/ax@1551 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/test')
87 files changed, 0 insertions, 18345 deletions
diff --git a/docutils/test/.cvsignore b/docutils/test/.cvsignore deleted file mode 100644 index b8af75aec..000000000 --- a/docutils/test/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*.pyc -alltests.out diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py deleted file mode 100644 index ebfc218f6..000000000 --- a/docutils/test/DocutilsTestSupport.py +++ /dev/null @@ -1,611 +0,0 @@ -# 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` - - `TransformTestSuite` - - `TransformTestCase` - - `ParserTestSuite` - - `ParserTestCase` - - `PEPParserTestSuite` - - `PEPParserTestCase` - - `GridTableParserTestSuite` - - `GridTableParserTestCase` - - `SimpleTableParserTestSuite` - - `SimpleTableParserTestCase` - - 'LatexPublishTestSuite' - - 'LatexPublishTestCase' - - `DevNull` (output sink) -""" -__docformat__ = 'reStructuredText' - -import sys -import os -import unittest -import difflib -import inspect -from pprint import pformat -from types import UnicodeType -import package_unittest -import docutils -import docutils.core -from docutils import frontend, nodes, statemachine, urischemes, utils -from docutils.transforms import universal -from docutils.parsers import rst -from docutils.parsers.rst import states, tableparser, directives, languages -from docutils.readers import standalone, pep, python -from docutils.statemachine import string2lines - -try: - from docutils.readers.python import moduleparser -except: - moduleparser = None - -try: - import mypdb as pdb -except: - import pdb - - - -class DevNull: - - """Output sink.""" - - def write(self, string): - pass - - -class CustomTestSuite(unittest.TestSuite): - - """ - A collection of custom TestCases. - - """ - - id = '' - """Identifier for the TestSuite. Prepended to the - TestCase identifiers to make identification easier.""" - - next_test_case_id = 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: - mypath = os.path.abspath( - sys.modules[CustomTestSuite.__module__].__file__) - outerframes = inspect.getouterframes(inspect.currentframe()) - for outerframe in outerframes[1:]: - if outerframe[3] != '__init__': - callerpath = outerframe[1] - if callerpath is None: - # It happens sometimes. Why is a mystery. - callerpath = os.getcwd() - callerpath = os.path.abspath(callerpath) - 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, test_case_class, method_name, input, expected, - id=None, run_in_debugger=0, short_description=None, - **kwargs): - """ - Create a custom TestCase in the CustomTestSuite. - Also return it, just in case. - - Arguments: - - test_case_class -- - method_name -- - input -- input to the parser. - expected -- expected output from the parser. - id -- unique test identifier, used by the test framework. - run_in_debugger -- if true, run this test under the pdb debugger. - short_description -- override to default test description. - """ - if id is None: # generate id if required - id = self.next_test_case_id - self.next_test_case_id += 1 - # test identifier will become suiteid.testid - tcid = '%s: %s' % (self.id, id) - # generate and add test case - tc = test_case_class(method_name, input, expected, tcid, - run_in_debugger=run_in_debugger, - short_description=short_description, - **kwargs) - self.addTest(tc) - return tc - - -class CustomTestCase(unittest.TestCase): - - compare = difflib.Differ().compare - """Comparison method shared by all subclasses.""" - - def __init__(self, method_name, input, expected, id, - run_in_debugger=0, short_description=None): - """ - Initialise the CustomTestCase. - - Arguments: - - method_name -- 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. - run_in_debugger -- if true, run this test under the pdb debugger. - short_description -- override to default test description. - """ - self.id = id - self.input = input - self.expected = expected - self.run_in_debugger = run_in_debugger - # Ring your mother. - unittest.TestCase.__init__(self, method_name) - - 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 compare_output(self, input, output, expected): - """`input`, `output`, and `expected` should all be strings.""" - if type(input) == UnicodeType: - input = input.encode('raw_unicode_escape') - if type(output) == UnicodeType: - output = output.encode('raw_unicode_escape') - if type(expected) == UnicodeType: - expected = expected.encode('raw_unicode_escape') - 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 - - def skip_test(self): - print >>sys.stderr, '%s: Test skipped' % self - - -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] - run_in_debugger = 0 - if len(case)==3: - if case[2]: - run_in_debugger = 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), - run_in_debugger=run_in_debugger) - - -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. - """ - - option_parser = frontend.OptionParser(components=(rst.Parser,)) - settings = option_parser.get_default_values() - settings.report_level = 1 - settings.halt_level = 5 - settings.debug = package_unittest.debug - settings.warning_stream = DevNull() - - 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 supports(self, format): - return 1 - - def test_transforms(self): - if self.run_in_debugger: - pdb.set_trace() - document = utils.new_document('test data', self.settings) - self.parser.parse(self.input, document) - # Don't do a ``populate_from_components()`` because that would - # enable the Transformer's default transforms. - document.transformer.add_transforms(self.transforms) - document.transformer.add_transform(universal.TestMessages) - document.transformer.components['writer'] = self - document.transformer.apply_transforms() - output = document.pformat() - self.compare_output(self.input, output, self.expected) - - def test_transforms_verbosely(self): - if self.run_in_debugger: - pdb.set_trace() - print '\n', self.id - print '-' * 70 - print self.input - document = utils.new_document('test data', self.settings) - self.parser.parse(self.input, document) - print '-' * 70 - print document.pformat() - for transformClass in self.transforms: - transformClass(document).apply() - output = document.pformat() - print '-' * 70 - print output - self.compare_output(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.""" - - option_parser = frontend.OptionParser(components=(parser,)) - settings = option_parser.get_default_values() - settings.report_level = 5 - settings.halt_level = 5 - settings.debug = package_unittest.debug - - def test_parser(self): - if self.run_in_debugger: - pdb.set_trace() - document = utils.new_document('test data', self.settings) - self.parser.parse(self.input, document) - output = document.pformat() - self.compare_output(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] - run_in_debugger = 0 - if len(case)==3: - if case[2]: - run_in_debugger = 1 - else: - continue - self.addTestCase( - self.test_case_class, 'test_parser', - input=case[0], expected=case[1], - id='%s[%r][%s]' % (dictname, name, casenum), - run_in_debugger=run_in_debugger) - - -class PEPParserTestCase(ParserTestCase): - - """PEP-specific parser test case.""" - - parser = rst.Parser(rfc2822=1, inliner=pep.Inliner()) - """Parser shared by all PEPParserTestCases.""" - - option_parser = frontend.OptionParser(components=(parser, pep.Reader)) - settings = option_parser.get_default_values() - settings.report_level = 5 - settings.halt_level = 5 - settings.debug = package_unittest.debug - - -class PEPParserTestSuite(ParserTestSuite): - - """A collection of PEPParserTestCases.""" - - test_case_class = PEPParserTestCase - - -class GridTableParserTestCase(CustomTestCase): - - parser = tableparser.GridTableParser() - - def test_parse_table(self): - self.parser.setup(string2lines(self.input)) - try: - self.parser.find_head_body_sep() - self.parser.parse_table() - output = self.parser.cells - except Exception, details: - output = '%s: %s' % (details.__class__.__name__, details) - self.compare_output(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.compare_output(self.input, pformat(output) + '\n', - pformat(self.expected) + '\n') - - -class GridTableParserTestSuite(CustomTestSuite): - - """ - A collection of GridTableParserTestCases. - - A GridTableParserTestSuite instance manufactures GridTableParserTestCases, - keeps track of them, and provides a shared test fixture (a-la setUp and - tearDown). - """ - - test_case_class = GridTableParserTestCase - - 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 parse_table(), - 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] - run_in_debugger = 0 - if len(case) == 4: - if case[-1]: - run_in_debugger = 1 - else: - continue - self.addTestCase(self.test_case_class, 'test_parse_table', - input=case[0], expected=case[1], - id='%s[%r][%s]' % (dictname, name, casenum), - run_in_debugger=run_in_debugger) - self.addTestCase(self.test_case_class, 'test_parse', - input=case[0], expected=case[2], - id='%s[%r][%s]' % (dictname, name, casenum), - run_in_debugger=run_in_debugger) - - -class SimpleTableParserTestCase(GridTableParserTestCase): - - parser = tableparser.SimpleTableParser() - - -class SimpleTableParserTestSuite(CustomTestSuite): - - """ - A collection of SimpleTableParserTestCases. - """ - - test_case_class = SimpleTableParserTestCase - - 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 parse(), 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] - run_in_debugger = 0 - if len(case) == 3: - if case[-1]: - run_in_debugger = 1 - else: - continue - self.addTestCase(self.test_case_class, 'test_parse', - input=case[0], expected=case[1], - id='%s[%r][%s]' % (dictname, name, casenum), - run_in_debugger=run_in_debugger) - - -class PythonModuleParserTestCase(CustomTestCase): - - def test_parser(self): - if self.run_in_debugger: - pdb.set_trace() - module = moduleparser.parse_module(self.input, 'test data') - output = str(module) - self.compare_output(self.input, output, self.expected) - - def test_token_parser_rhs(self): - if self.run_in_debugger: - pdb.set_trace() - tr = moduleparser.TokenParser(self.input) - output = tr.rhs(1) - self.compare_output(self.input, output, self.expected) - - -class PythonModuleParserTestSuite(CustomTestSuite): - - """ - A collection of PythonModuleParserTestCase. - """ - - if moduleparser is None: - PythonModuleParserTestCase.test_parser = CustomTestCase.skip_test - PythonModuleParserTestCase.test_token_parser_rhs = \ - CustomTestCase.skip_test - - def generateTests(self, dict, dictname='totest', - testmethod='test_parser'): - """ - Stock the suite with test cases generated from a test data dictionary. - - Each dictionary key (test type's 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] - run_in_debugger = 0 - if len(case)==3: - if case[2]: - run_in_debugger = 1 - else: - continue - self.addTestCase( - PythonModuleParserTestCase, testmethod, - input=case[0], expected=case[1], - id='%s[%r][%s]' % (dictname, name, casenum), - run_in_debugger=run_in_debugger) - - -# @@@ These should be generalized to WriterPublishTestCase/Suite or -# just PublishTestCase/Suite, as per TransformTestCase/Suite. -class LatexPublishTestCase(CustomTestCase, docutils.SettingsSpec): - - """ - Test case for publish. - """ - - settings_default_overrides = {'_disable_config': 1} - - def test_publish(self): - if self.run_in_debugger: - pdb.set_trace() - output = docutils.core.publish_string( - source=self.input, - reader_name='standalone', - parser_name='restructuredtext', - writer_name='latex', - settings_spec=self) - self.compare_output(self.input, output, self.expected) - - -class LatexPublishTestSuite(CustomTestSuite): - - def __init__(self): - CustomTestSuite.__init__(self) - - def generateTests(self, dict, dictname='totest'): - for name, cases in dict.items(): - for casenum in range(len(cases)): - case = cases[casenum] - run_in_debugger = 0 - if len(case)==3: - if case[2]: - run_in_debugger = 1 - else: - continue - self.addTestCase( - LatexPublishTestCase, 'test_publish', - input=case[0], expected=case[1], - id='%s[%r][%s]' % (dictname, name, casenum), - run_in_debugger=run_in_debugger) - - -def exception_args(code): - try: - exec(code) - except Exception, detail: - return detail.args diff --git a/docutils/test/alltests.py b/docutils/test/alltests.py deleted file mode 100755 index 8cacec5f2..000000000 --- a/docutils/test/alltests.py +++ /dev/null @@ -1,70 +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 -import 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): - self.stream.write(string) - self.file.write(string) - - def flush(self): - self.stream.flush() - self.file.flush() - - -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) - - -# must redirect stderr *before* first import of unittest -sys.stdout = sys.stderr = Tee('alltests.out') - -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 019d6fb38..000000000 --- a/docutils/test/package_unittest.py +++ /dev/null @@ -1,156 +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 -import os -import getopt -import types -import unittest -import 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 = [] - path = os.path.abspath(path) # current working dir if `path` empty - paths = [path] - while paths: - p = paths.pop(0) - files = os.listdir(p) - for filename in files: - if filename.startswith(name): - fullpath = os.path.join(p, filename) - if filename.endswith('.py'): - fullpath = fullpath[len(path)+1:] - testModules.append(path2mod(fullpath)) - 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_language.py b/docutils/test/test_language.py deleted file mode 100644 index cf9d75804..000000000 --- a/docutils/test/test_language.py +++ /dev/null @@ -1,210 +0,0 @@ -#!/usr/bin/env python - -# Authors: Engelbert Gruber; David Goodger -# Contact: grubert@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for language module completeness. - -Specify a language code (e.g. "de") as a command-line parameter to test only -that language. -""" - -import sys -import os -import re -from types import UnicodeType -import docutils.languages -import docutils.parsers.rst.languages -from docutils.parsers.rst import states, directives -from DocutilsTestSupport import CustomTestSuite, CustomTestCase - -reference_language = 'en' - - -class LanguageTestSuite(CustomTestSuite): - - language_module_pattern = re.compile('^([a-z]{2,3}(_[a-z]{2,8})*)\.py$') - - def __init__(self, languages=None): - CustomTestSuite.__init__(self) - if languages: - self.languages = languages - else: - self.get_languages() - - def get_languages(self): - """ - Get installed language translations from docutils.languages and from - docutils.parsers.rst.languages. - """ - languages = {} - for mod in (os.listdir(docutils.languages.__path__[0]) - + os.listdir(docutils.parsers.rst.languages.__path__[0])): - match = self.language_module_pattern.match(mod) - if match: - languages[match.group(1)] = 1 - self.languages = languages.keys() - - def generateTests(self): - for language in self.languages: - for method in LanguageTestCase.test_methods: - self.addTestCase(LanguageTestCase, method, None, None, - id=language+'.py', language=language) - - -class LanguageTestCase(CustomTestCase): - - test_methods = ['test_labels', 'test_bibliographic_fields', - 'test_directives', 'test_roles'] - """Names of methods used to test each language.""" - - def __init__(self, *args, **kwargs): - self.ref = docutils.languages.get_language(reference_language) - self.language = kwargs['language'] - del kwargs['language'] # only wanted here - CustomTestCase.__init__(self, *args, **kwargs) - - def _xor(self, ref_dict, l_dict): - """ - Returns entries that are only in one dictionary. - (missing_in_lang, more_than_in_ref). - """ - missing = [] # in ref but not in l. - too_much = [] # in l but not in ref. - for label in ref_dict.keys(): - if not l_dict.has_key(label): - missing.append(label) - for label in l_dict.keys(): - if not ref_dict.has_key(label): - too_much.append(label) - return (missing, too_much) - - def _invert(self, adict): - """Return an inverted (keys & values swapped) dictionary.""" - inverted = {} - for key, value in adict.items(): - inverted[value] = key - return inverted - - def test_labels(self): - try: - module = docutils.languages.get_language(self.language) - if not module: - raise ImportError - except ImportError: - self.fail('No docutils.languages.%s module.' % self.language) - missed, unknown = self._xor(self.ref.labels, module.labels) - if missed or unknown: - self.fail('Module docutils.languages.%s.labels:\n' - ' Missed: %s; Unknown: %s' - % (self.language, str(missed), str(unknown))) - - def test_bibliographic_fields(self): - try: - module = docutils.languages.get_language(self.language) - if not module: - raise ImportError - except ImportError: - self.fail('No docutils.languages.%s module.' % self.language) - missed, unknown = self._xor( - self._invert(self.ref.bibliographic_fields), - self._invert(module.bibliographic_fields)) - if missed or unknown: - self.fail('Module docutils.languages.%s.bibliographic_fields:\n' - ' Missed: %s; Unknown: %s' - % (self.language, str(missed), str(unknown))) - - def test_directives(self): - try: - module = docutils.parsers.rst.languages.get_language( - self.language) - if not module: - raise ImportError - except ImportError: - self.fail('No docutils.parsers.rst.languages.%s module.' - % self.language) - failures = [] - for d in module.directives.keys(): - try: - func, msg = directives.directive(d, module, None) - if not func: - failures.append('"%s": unknown directive' % d) - except Exception, error: - failures.append('"%s": %s' % (d, error)) - inverted = self._invert(module.directives) - canonical = directives._directive_registry.keys() - canonical.sort() - canonical.remove('restructuredtext-test-directive') - for name in canonical: - if not inverted.has_key(name): - failures.append('"%s": translation missing' % name) - if failures: - text = ('Module docutils.parsers.rst.languages.%s:\n %s' - % (self.language, '\n '.join(failures))) - if type(text) == UnicodeType: - text = text.encode('raw_unicode_escape') - self.fail(text) - - def test_roles(self): - try: - module = docutils.parsers.rst.languages.get_language( - self.language) - if not module: - raise ImportError - module.roles - except ImportError: - self.fail('No docutils.parsers.rst.languages.%s module.' - % self.language) - except AttributeError: - self.fail('No "roles" mapping in docutils.parsers.rst.languages.' - '%s module.' % self.language) - failures = [] - for d in module.roles.values(): - try: - method = states.Inliner._interpreted_roles[d] - #if not method: - # failures.append('"%s": unknown role' % d) - except KeyError, error: - failures.append('"%s": %s' % (d, error)) - inverted = self._invert(module.roles) - canonical = states.Inliner._interpreted_roles.keys() - canonical.sort() - canonical.remove('restructuredtext-unimplemented-role') - for name in canonical: - if not inverted.has_key(name): - failures.append('"%s": translation missing' % name) - if failures: - text = ('Module docutils.parsers.rst.languages.%s:\n %s' - % (self.language, '\n '.join(failures))) - if type(text) == UnicodeType: - text = text.encode('raw_unicode_escape') - self.fail(text) - - -languages_to_test = [] - -def suite(): - s = LanguageTestSuite(languages_to_test) - s.generateTests() - return s - -def get_language_arguments(): - while len(sys.argv) > 1: - last = sys.argv[-1] - if last.startswith('-'): - break - languages_to_test.append(last) - sys.argv.pop() - languages_to_test.reverse() - - -if __name__ == '__main__': - get_language_arguments() - import unittest - unittest.main(defaultTest='suite') - -# vim: set et ts=4 ai : diff --git a/docutils/test/test_nodes.py b/docutils/test/test_nodes.py deleted file mode 100755 index 4258d7817..000000000 --- a/docutils/test/test_nodes.py +++ /dev/null @@ -1,153 +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 types import ClassType -from DocutilsTestSupport import nodes, utils - -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_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') - del element['attr'] - element['mark'] = u'\u2022' - self.assertEquals(repr(element), '<Element: >') - self.assertEquals(str(element), '<Element mark="\\u2022"/>') - dom = element.asdom() - self.assertEquals(dom.toxml(), u'<Element mark="\u2022"/>') - dom.unlink() - - 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 -""") - - -class MiscTests(unittest.TestCase): - - def test_node_class_names(self): - node_class_names = [] - for x in dir(nodes): - c = getattr(nodes, x) - if type(c) is ClassType and issubclass(c, nodes.Node) \ - and len(c.__bases__) > 1: - node_class_names.append(x) - node_class_names.sort() - nodes.node_class_names.sort() - self.assertEquals(node_class_names, nodes.node_class_names) - - 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_make_id(self): - for input, output in self.ids: - normed = nodes.make_id(input) - self.assertEquals(normed, output) - - -class TreeCopyVisitorTests(unittest.TestCase): - - def setUp(self): - document = utils.new_document('test data') - document += nodes.paragraph('', 'Paragraph 1.') - blist = nodes.bullet_list() - for i in range(1, 6): - item = nodes.list_item() - for j in range(1, 4): - item += nodes.paragraph('', 'Item %s, paragraph %s.' % (i, j)) - blist += item - document += blist - self.document = document - - def compare_trees(self, one, two): - self.assertEquals(one.__class__, two.__class__) - self.assertNotEquals(id(one), id(two)) - children1 = one.get_children() - children2 = two.get_children() - self.assertEquals(len(children1), len(children2)) - for i in range(len(children1)): - self.compare_trees(children1[i], children2[i]) - - def test_copy_whole(self): - visitor = nodes.TreeCopyVisitor(self.document) - self.document.walkabout(visitor) - newtree = visitor.get_tree_copy() - self.assertEquals(self.document.pformat(), newtree.pformat()) - self.compare_trees(self.document, newtree) - - -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_normalize_name(self): - for input, output in self.names: - normed = nodes.fully_normalize_name(input) - self.assertEquals(normed, output) - - -if __name__ == '__main__': - unittest.main() diff --git a/docutils/test/test_parsers/__init__.py b/docutils/test/test_parsers/__init__.py deleted file mode 100644 index 2fe79c55c..000000000 --- a/docutils/test/test_parsers/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import os.path -import sys - -sys.path.insert(0, os.path.abspath(os.curdir)) -prev = '' -while sys.path[0] != prev: - try: - import DocutilsTestSupport - break - except ImportError: - prev = sys.path[0] - sys.path[0] = os.path.dirname(prev) -sys.path.pop(0) diff --git a/docutils/test/test_parsers/test_rst/__init__.py b/docutils/test/test_parsers/test_rst/__init__.py deleted file mode 100644 index 2fe79c55c..000000000 --- a/docutils/test/test_parsers/test_rst/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import os.path -import sys - -sys.path.insert(0, os.path.abspath(os.curdir)) -prev = '' -while sys.path[0] != prev: - try: - import DocutilsTestSupport - break - except ImportError: - prev = sys.path[0] - sys.path[0] = os.path.dirname(prev) -sys.path.pop(0) diff --git a/docutils/test/test_parsers/test_rst/includes/include9.txt b/docutils/test/test_parsers/test_rst/includes/include9.txt deleted file mode 100644 index 9164722b3..000000000 --- a/docutils/test/test_parsers/test_rst/includes/include9.txt +++ /dev/null @@ -1,3 +0,0 @@ -In ../includes/include9.txt. - -.. include:: ../test_directives/include2.txt diff --git a/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py b/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py deleted file mode 100644 index 3bb669db1..000000000 --- a/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py +++ /dev/null @@ -1,101 +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.SimpleTableParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['simple_tables'] = [ -["""\ -============ ============ -A table with two columns. -============ ============ -""", -([12, 12], - [], - [[(0, 0, 1, ['A table with']), - (0, 0, 1, ['two columns.'])]])], -["""\ -============ ============ -A table with two columns -and two rows. -============ ============ -""", -([12, 12], - [], - [[(0, 0, 1, ['A table with']), - (0, 0, 1, ['two columns'])], - [(0, 0, 2, ['and']), - (0, 0, 2, ['two rows.'])]])], -["""\ -========== =========== -A table with four rows, ------------------------ -and two columns. -First and last rows -contain column spans. -======================= -""", -([10, 11], - [], - [[(0, 1, 1, ['A table with four rows,'])], - [(0, 0, 3, ['and two']), - (0, 0, 3, ['columns.'])], - [(0, 0, 4, ['First and']), - (0, 0, 4, ['last rows'])], - [(0, 1, 5, ['contain column spans.'])]])], -["""\ -======= ===== ====== -A bad table cell 2 -cell 3 cell 4 -============ ====== -""", -'TableMarkupError: Text in column margin at line offset 1.'], -["""\ -=========== ================ -A table with two header rows, ------------------------------ -the first with a span. -=========== ================ -Two body rows, -the second with a span. -============================= -""", -([11, 16], - [[(0, 1, 1, ['A table with two header rows,'])], - [(0, 0, 3, ['the first']), - (0, 0, 3, ['with a span.'])]], - [[(0, 0, 5, ['Two body']), - (0, 0, 5, ['rows,'])], - [(0, 1, 6, ['the second with a span.'])]])], -["""\ -============ ============= -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.'], -] - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') 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 08b13fc8c..000000000 --- a/docutils/test/test_parsers/test_rst/test_TableParser.py +++ /dev/null @@ -1,198 +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.GridTableParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['grid_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 276e0132c..000000000 --- a/docutils/test/test_parsers/test_rst/test_block_quotes.py +++ /dev/null @@ -1,252 +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 source="test data"> - <paragraph> - Line 1. - Line 2. - <block_quote> - <paragraph> - Indented. -"""], -["""\ -Line 1. -Line 2. - - Indented 1. - - Indented 2. -""", -"""\ -<document source="test data"> - <paragraph> - Line 1. - Line 2. - <block_quote> - <paragraph> - Indented 1. - <block_quote> - <paragraph> - Indented 2. -"""], -["""\ -Line 1. -Line 2. - Unexpectedly indented. -""", -"""\ -<document source="test data"> - <paragraph> - Line 1. - Line 2. - <system_message level="3" line="3" source="test data" type="ERROR"> - <paragraph> - Unexpected indentation. - <block_quote> - <paragraph> - Unexpectedly indented. -"""], -["""\ -Line 1. -Line 2. - - Indented. -no blank line -""", -"""\ -<document source="test data"> - <paragraph> - Line 1. - Line 2. - <block_quote> - <paragraph> - Indented. - <system_message level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Block quote ends without a blank line; unexpected unindent. - <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 source="test data"> - <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. -"""], -["""\ -Paragraph. - - Block quote. - - -- Attribution - -Paragraph. - - Block quote. - - --Attribution -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph. - <block_quote> - <paragraph> - Block quote. - <attribution> - Attribution - <paragraph> - Paragraph. - <block_quote> - <paragraph> - Block quote. - <attribution> - Attribution -"""], -["""\ -Paragraph. - - Block quote. - - -- Attribution line one - and line two - -Paragraph. - - Block quote. - - -- Attribution line one - and line two -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph. - <block_quote> - <paragraph> - Block quote. - <attribution> - Attribution line one - and line two - <paragraph> - Paragraph. - <block_quote> - <paragraph> - Block quote. - <attribution> - Attribution line one - and line two -"""], -["""\ -Paragraph. - - -- Not an attribution - -Paragraph. - - Block quote. - - \-- Not an attribution - -Paragraph. - - Block quote. - - --- Not an attribution - -Paragraph. - - Block quote. - - -- Not an attribution line one - and line two - and line three -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph. - <block_quote> - <paragraph> - -- Not an attribution - <paragraph> - Paragraph. - <block_quote> - <paragraph> - Block quote. - <paragraph> - -- Not an attribution - <paragraph> - Paragraph. - <block_quote> - <paragraph> - Block quote. - <paragraph> - --- Not an attribution - <paragraph> - Paragraph. - <block_quote> - <paragraph> - Block quote. - <definition_list> - <definition_list_item> - <term> - -- Not an attribution line one - <definition> - <definition_list> - <definition_list_item> - <term> - and line two - <definition> - <paragraph> - and line three -"""], -] - -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 12ede6cf1..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 source="test data"> - <bullet_list bullet="-"> - <list_item> - <paragraph> - item -"""], -["""\ -* item 1 - -* item 2 -""", -"""\ -<document source="test data"> - <bullet_list bullet="*"> - <list_item> - <paragraph> - item 1 - <list_item> - <paragraph> - item 2 -"""], -["""\ -No blank line between: - -+ item 1 -+ item 2 -""", -"""\ -<document source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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" line="8" source="test data" type="WARNING"> - <paragraph> - Bullet list ends without a blank line; unexpected unindent. - <bullet_list bullet="-"> - <list_item> - <paragraph> - item 4 -"""], -["""\ -- item -no blank line -""", -"""\ -<document source="test data"> - <bullet_list bullet="-"> - <list_item> - <paragraph> - item - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Bullet list ends without a blank line; unexpected unindent. - <paragraph> - no blank line -"""], -["""\ -- - -empty item above -""", -"""\ -<document source="test data"> - <bullet_list bullet="-"> - <list_item> - <paragraph> - empty item above -"""], -["""\ -- -empty item above, no blank line -""", -"""\ -<document source="test data"> - <bullet_list bullet="-"> - <list_item> - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Bullet list ends without a blank line; unexpected unindent. - <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 a92e151a4..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 source="test data"> - <citation id="citation" name="citation"> - <label> - citation - <paragraph> - This is a citation. -"""], -["""\ -.. [citation1234] This is a citation with year. -""", -"""\ -<document source="test data"> - <citation id="citation1234" name="citation1234"> - <label> - citation1234 - <paragraph> - This is a citation with year. -"""], -["""\ -.. [citation] This is a citation - on multiple lines. -""", -"""\ -<document source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <citation id="citation" name="citation"> - <label> - citation - <paragraph> - That was an empty citation. -"""], -["""\ -.. [citation] -No blank line. -""", -"""\ -<document source="test data"> - <citation id="citation" name="citation"> - <label> - citation - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <paragraph> - No blank line. -"""], -["""\ -.. [citation label with spaces] this isn't a citation - -.. [*citationlabelwithmarkup*] this isn't a citation -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - [citation label with spaces] this isn't a citation - <comment xml:space="preserve"> - [*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 a90135ec5..000000000 --- a/docutils/test/test_parsers/test_rst/test_comments.py +++ /dev/null @@ -1,319 +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 source="test data"> - <comment xml:space="preserve"> - A comment - <paragraph> - Paragraph. -"""], -["""\ -.. A comment - block. - -Paragraph. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - A comment - block. - <paragraph> - Paragraph. -"""], -["""\ -.. - A comment consisting of multiple lines - starting on the line after the - explicit markup start. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - A comment consisting of multiple lines - starting on the line after the - explicit markup start. -"""], -["""\ -.. A comment. -.. Another. - -Paragraph. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - A comment. - <comment xml:space="preserve"> - Another. - <paragraph> - Paragraph. -"""], -["""\ -.. A comment -no blank line - -Paragraph. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - A comment - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <paragraph> - no blank line - <paragraph> - Paragraph. -"""], -["""\ -.. A comment. -.. Another. -no blank line - -Paragraph. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - A comment. - <comment xml:space="preserve"> - Another. - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <paragraph> - no blank line - <paragraph> - Paragraph. -"""], -["""\ -.. A comment:: - -Paragraph. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - A comment:: - <paragraph> - Paragraph. -"""], -["""\ -.. - comment:: - -The extra newline before the comment text prevents -the parser from recognizing a directive. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - comment:: - <paragraph> - The extra newline before the comment text prevents - the parser from recognizing a directive. -"""], -["""\ -.. - _comment: http://example.org - -The extra newline before the comment text prevents -the parser from recognizing a hyperlink target. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - _comment: http://example.org - <paragraph> - The extra newline before the comment text prevents - the parser from recognizing a hyperlink target. -"""], -["""\ -.. - [comment] Not a citation. - -The extra newline before the comment text prevents -the parser from recognizing a citation. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - [comment] Not a citation. - <paragraph> - The extra newline before the comment text prevents - the parser from recognizing a citation. -"""], -["""\ -.. - |comment| image:: bogus.png - -The extra newline before the comment text prevents -the parser from recognizing a substitution definition. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - |comment| image:: bogus.png - <paragraph> - The extra newline before the comment text prevents - the parser from recognizing a substitution definition. -"""], -["""\ -.. Next is an empty comment, which serves to end this comment and - prevents the following block quote being swallowed up. - -.. - - A block quote. -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - Next is an empty comment, which serves to end this comment and - prevents the following block quote being swallowed up. - <comment xml:space="preserve"> - <block_quote> - <paragraph> - A block quote. -"""], -["""\ -term 1 - definition 1 - - .. a comment - -term 2 - definition 2 -""", -"""\ -<document source="test data"> - <definition_list> - <definition_list_item> - <term> - term 1 - <definition> - <paragraph> - definition 1 - <comment xml:space="preserve"> - a comment - <definition_list_item> - <term> - term 2 - <definition> - <paragraph> - definition 2 -"""], -["""\ -term 1 - definition 1 - -.. a comment - -term 2 - definition 2 -""", -"""\ -<document source="test data"> - <definition_list> - <definition_list_item> - <term> - term 1 - <definition> - <paragraph> - definition 1 - <comment xml:space="preserve"> - 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 source="test data"> - <bullet_list bullet="+"> - <list_item> - <paragraph> - bullet paragraph 1 - <paragraph> - bullet paragraph 2 - <comment xml:space="preserve"> - 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 source="test data"> - <bullet_list bullet="+"> - <list_item> - <paragraph> - bullet paragraph 1 - <comment xml:space="preserve"> - comment between bullet paragraphs 1 (leader) and 2 - <paragraph> - bullet paragraph 2 -"""], -["""\ -+ bullet - - .. trailing comment -""", -"""\ -<document source="test data"> - <bullet_list bullet="+"> - <list_item> - <paragraph> - bullet - <comment xml:space="preserve"> - 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 2cb0a6082..000000000 --- a/docutils/test/test_parsers/test_rst/test_definition_lists.py +++ /dev/null @@ -1,377 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for states.py. -""" - -from __init__ import DocutilsTestSupport - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['definition_lists'] = [ -["""\ -term - definition -""", -"""\ -<document source="test data"> - <definition_list> - <definition_list_item> - <term> - term - <definition> - <paragraph> - definition -"""], -["""\ -term - definition - -paragraph -""", -"""\ -<document source="test data"> - <definition_list> - <definition_list_item> - <term> - term - <definition> - <paragraph> - definition - <paragraph> - paragraph -"""], -["""\ -term - definition -no blank line -""", -"""\ -<document source="test data"> - <definition_list> - <definition_list_item> - <term> - term - <definition> - <paragraph> - definition - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Definition list ends without a blank line; unexpected unindent. - <paragraph> - no blank line -"""], -["""\ -A paragraph:: - A literal block without a blank line first? -""", -"""\ -<document source="test data"> - <definition_list> - <definition_list_item> - <term> - A paragraph:: - <definition> - <system_message level="1" line="2" source="test data" type="INFO"> - <paragraph> - Blank line missing before literal block? Interpreted as a definition list item. - <paragraph> - A literal block without a blank line first? -"""], -["""\ -this is not a term; -a term may only be one line long - this is not a definition -""", -"""\ -<document source="test data"> - <paragraph> - this is not a term; - a term may only be one line long - <system_message level="3" line="3" source="test data" type="ERROR"> - <paragraph> - Unexpected indentation. - <block_quote> - <paragraph> - this is not a definition -"""], -["""\ -term 1 - definition 1 - -term 2 - definition 2 -""", -"""\ -<document source="test data"> - <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 source="test data"> - <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 (no blank line below) -term 2 - definition 2 -No blank line after the definition list. -""", -"""\ -<document source="test data"> - <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 - <system_message level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Definition list ends without a blank line; unexpected unindent. - <paragraph> - No blank line after the definition list. -"""], -["""\ -term 1 - definition 1 - - term 1a - definition 1a - - term 1b - definition 1b - -term 2 - definition 2 - -paragraph -""", -"""\ -<document source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 : not a classifier`` - Because the ' : ' is inside an inline literal. -""", -"""\ -<document source="test data"> - <definition_list> - <definition_list_item> - <term> - <literal> - Term : not a classifier - <definition> - <paragraph> - Because the ' : ' is inside an inline literal. -"""], -["""\ -Term `with *inline ``text **errors : classifier `with *errors ``too - Definition `with *inline ``text **markup errors. -""", -"""\ -<document source="test data"> - <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" line="1" source="test data" type="WARNING"> - <paragraph> - Inline interpreted text or phrase reference start-string without end-string. - <system_message backrefs="id4" id="id3" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline emphasis start-string without end-string. - <system_message backrefs="id6" id="id5" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline literal start-string without end-string. - <system_message backrefs="id8" id="id7" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline strong start-string without end-string. - <system_message backrefs="id10" id="id9" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline interpreted text or phrase reference start-string without end-string. - <system_message backrefs="id12" id="id11" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline emphasis start-string without end-string. - <system_message backrefs="id14" id="id13" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline literal start-string without end-string. - <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" line="2" source="test data" type="WARNING"> - <paragraph> - Inline interpreted text or phrase reference start-string without end-string. - <system_message backrefs="id18" id="id17" level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Inline emphasis start-string without end-string. - <system_message backrefs="id20" id="id19" level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Inline literal start-string without end-string. - <system_message backrefs="id22" id="id21" level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Inline strong start-string without end-string. -"""], -] - -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 2fe79c55c..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import os.path -import sys - -sys.path.insert(0, os.path.abspath(os.curdir)) -prev = '' -while sys.path[0] != prev: - try: - import DocutilsTestSupport - break - except ImportError: - prev = sys.path[0] - sys.path[0] = os.path.dirname(prev) -sys.path.pop(0) diff --git a/docutils/test/test_parsers/test_rst/test_directives/include1.txt b/docutils/test/test_parsers/test_rst/test_directives/include1.txt deleted file mode 100644 index 82f605320..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/include1.txt +++ /dev/null @@ -1,4 +0,0 @@ -Inclusion 1 ------------ - -This file is used by ``test_include.py``. diff --git a/docutils/test/test_parsers/test_rst/test_directives/include2.txt b/docutils/test/test_parsers/test_rst/test_directives/include2.txt deleted file mode 100644 index 5b76a7052..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/include2.txt +++ /dev/null @@ -1,5 +0,0 @@ -Here are some paragraphs -that can appear at any level. - -This file (include2.txt) is used by -``test_include.py``. diff --git a/docutils/test/test_parsers/test_rst/test_directives/include3.txt b/docutils/test/test_parsers/test_rst/test_directives/include3.txt deleted file mode 100644 index 9996a4452..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/include3.txt +++ /dev/null @@ -1,3 +0,0 @@ -In include3.txt - -.. include:: includes/include4.txt diff --git a/docutils/test/test_parsers/test_rst/test_directives/include8.txt b/docutils/test/test_parsers/test_rst/test_directives/include8.txt deleted file mode 100644 index e7fc57a3d..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/include8.txt +++ /dev/null @@ -1,3 +0,0 @@ -In include8.txt - -.. include:: ../includes/include9.txt diff --git a/docutils/test/test_parsers/test_rst/test_directives/include9.txt b/docutils/test/test_parsers/test_rst/test_directives/include9.txt deleted file mode 100644 index 8eb5b1720..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/include9.txt +++ /dev/null @@ -1,7 +0,0 @@ -.. |bad| unicode:: 0xFFFFFFFFF - -hi ------ - -hi ------ diff --git a/docutils/test/test_parsers/test_rst/test_directives/includes/include4.txt b/docutils/test/test_parsers/test_rst/test_directives/includes/include4.txt deleted file mode 100644 index 384772a77..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/includes/include4.txt +++ /dev/null @@ -1,3 +0,0 @@ -In includes/include4.txt - -.. include:: include5.txt diff --git a/docutils/test/test_parsers/test_rst/test_directives/includes/include5.txt b/docutils/test/test_parsers/test_rst/test_directives/includes/include5.txt deleted file mode 100644 index 64b3e3aa2..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/includes/include5.txt +++ /dev/null @@ -1,3 +0,0 @@ -In includes/include5.txt - -.. include:: more/include6.txt diff --git a/docutils/test/test_parsers/test_rst/test_directives/includes/more/include6.txt b/docutils/test/test_parsers/test_rst/test_directives/includes/more/include6.txt deleted file mode 100644 index 8ac403b01..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/includes/more/include6.txt +++ /dev/null @@ -1,3 +0,0 @@ -In includes/more/include6.txt - -.. include:: ../sibling/include7.txt diff --git a/docutils/test/test_parsers/test_rst/test_directives/includes/sibling/include7.txt b/docutils/test/test_parsers/test_rst/test_directives/includes/sibling/include7.txt deleted file mode 100644 index fe85aa963..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/includes/sibling/include7.txt +++ /dev/null @@ -1 +0,0 @@ -In includes/sibling/include7.txt diff --git a/docutils/test/test_parsers/test_rst/test_directives/raw1.txt b/docutils/test/test_parsers/test_rst/test_directives/raw1.txt deleted file mode 100644 index 7ea03651b..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/raw1.txt +++ /dev/null @@ -1 +0,0 @@ -<p>This file is used by <tt>test_raw.py</tt>.</p> 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 af24935c1..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py +++ /dev/null @@ -1,184 +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 source="test data"> - <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 source="test data"> - <note> - <paragraph> - One-line notes. - <note> - <paragraph> - One after the other. - <note> - <paragraph> - No blank lines in-between. -"""], -["""\ -.. note:: -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - The "note" admonition is empty; content required. - <literal_block xml:space="preserve"> - .. note:: -"""], -["""\ -.. admonition:: Admonition - - This is a generic admonition. -""", -"""\ -<document source="test data"> - <admonition class="admonition-admonition"> - <title> - Admonition - <paragraph> - This is a generic admonition. -"""], -["""\ -.. admonition:: And, by the way... - - You can make up your own admonition too. -""", -"""\ -<document source="test data"> - <admonition class="admonition-and-by-the-way"> - <title> - And, by the way... - <paragraph> - You can make up your own admonition too. -"""], -["""\ -.. admonition:: Admonition - :class: emergency - - Test the "class" override. -""", -"""\ -<document source="test data"> - <admonition class="emergency"> - <title> - Admonition - <paragraph> - Test the "class" override. -"""], -["""\ -.. admonition:: - - Generic admonitions require a title. -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "admonition" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - .. admonition:: - - Generic admonitions require a title. -"""], -] - - -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 de5913708..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_contents.py +++ /dev/null @@ -1,208 +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 parts.py contents directive. -""" - -from __init__ import DocutilsTestSupport - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['contents'] = [ -["""\ -.. contents:: -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.parts.Contents - .details: - title: None -"""], -["""\ -.. contents:: Table of Contents -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.parts.Contents - .details: - title: - <title> - Table of Contents -"""], -["""\ -.. contents:: - Table of Contents -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.parts.Contents - .details: - title: - <title> - Table of Contents -"""], -["""\ -.. contents:: Table - of - Contents -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.parts.Contents - .details: - title: - <title> - Table - of - Contents -"""], -["""\ -.. contents:: *Table* of ``Contents`` -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.parts.Contents - .details: - title: - <title> - <emphasis> - Table - of \n\ - <literal> - Contents -"""], -["""\ -.. contents:: - :depth: 2 - :local: -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.parts.Contents - .details: - depth: 2 - local: None - title: None -"""], -["""\ -.. contents:: - :local: arg -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "contents" directive: - invalid option value: (option: "local"; value: 'arg') - no argument is allowed; "arg" supplied. - <literal_block xml:space="preserve"> - .. contents:: - :local: arg -"""], -["""\ -.. contents:: Table of Contents - :local: - :depth: 2 - :backlinks: none -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.parts.Contents - .details: - backlinks: None - depth: 2 - local: None - title: - <title> - Table of Contents -"""], -["""\ -.. contents:: - :depth: two -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "contents" directive: - invalid option value: (option: "depth"; value: 'two') - invalid literal for int(): two. - <literal_block xml:space="preserve"> - .. contents:: - :depth: two -"""], -["""\ -.. contents:: - :width: 2 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "contents" directive: - unknown option: "width". - <literal_block xml:space="preserve"> - .. contents:: - :width: 2 -"""], -["""\ -.. contents:: - :backlinks: no way! -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "contents" directive: - invalid option value: (option: "backlinks"; value: 'no way!') - "no way!" unknown; choose from "top", "entry", or "none". - <literal_block xml:space="preserve"> - .. contents:: - :backlinks: no way! -"""], -["""\ -.. contents:: - :backlinks: -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "contents" directive: - invalid option value: (option: "backlinks"; value: None) - must supply an argument; choose from "top", "entry", or "none". - <literal_block xml:space="preserve"> - .. contents:: - :backlinks: -"""], -] - - -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 888744bad..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_figures.py +++ /dev/null @@ -1,287 +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 source="test data"> - <figure> - <image uri="picture.png"> -"""], -["""\ -.. figure:: not an image URI -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Image URI contains whitespace. - <literal_block xml:space="preserve"> - .. figure:: not an image URI -"""], -["""\ -.. figure:: picture.png - - A picture with a caption. -""", -"""\ -<document source="test data"> - <figure> - <image uri="picture.png"> - <caption> - A picture with a caption. -"""], -["""\ -.. figure:: picture.png - - - A picture with an invalid caption. -""", -"""\ -<document source="test data"> - <figure> - <image uri="picture.png"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Figure caption must be a paragraph or empty comment. - <literal_block xml:space="preserve"> - .. figure:: picture.png - \n\ - - A picture with an invalid caption. -"""], -["""\ -.. figure:: not an image URI - - And a caption. -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Image URI contains whitespace. - <literal_block xml:space="preserve"> - .. figure:: not an image URI - \n\ - And a caption. -"""], -["""\ -.. figure:: picture.png - - .. - - A picture with a legend but no caption. -""", -"""\ -<document source="test data"> - <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 options and a caption. -""", -"""\ -<document source="test data"> - <figure> - <image height="100" scale="50" uri="picture.png" width="200"> - <caption> - A picture with image options and a caption. -"""], -["""\ -.. Figure:: picture.png - :height: 100 - :alt: alternate text - :width: 200 - :scale: 50 - :figwidth: 300 - - A picture with image options on individual lines, and this caption. -""", -"""\ -<document source="test data"> - <figure width="300"> - <image alt="alternate text" height="100" scale="50" uri="picture.png" width="200"> - <caption> - A picture with image options 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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 cde08dfe6..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_images.py +++ /dev/null @@ -1,249 +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 source="test data"> - <image uri="picture.png"> -"""], -["""\ -.. image:: -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - .. image:: -"""], -["""\ -.. image:: one two three -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Image URI contains whitespace. - <literal_block xml:space="preserve"> - .. image:: one two three -"""], -["""\ -.. image:: picture.png - :height: 100 - :width: 200 - :scale: 50 -""", -"""\ -<document source="test data"> - <image height="100" scale="50" uri="picture.png" width="200"> -"""], -["""\ -.. image:: - picture.png - :height: 100 - :width: 200 - :scale: 50 -""", -"""\ -<document source="test data"> - <image height="100" scale="50" uri="picture.png" width="200"> -"""], -["""\ -.. image:: - :height: 100 - :width: 200 - :scale: 50 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - .. image:: - :height: 100 - :width: 200 - :scale: 50 -"""], -["""\ -.. image:: a/very/long/path/to/ - picture.png - :height: 100 - :width: 200 - :scale: 50 -""", -"""\ -<document source="test data"> - <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 source="test data"> - <image alt="Alternate text for the picture" height="100" scale="50" uri="picture.png" width="200"> -"""], -["""\ -.. image:: picture.png - :scale: - 50 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - invalid option value: (option: "scale"; value: '- 50') - negative value; must be positive or zero. - <literal_block xml:space="preserve"> - .. image:: picture.png - :scale: - 50 -"""], -["""\ -.. image:: picture.png - :scale: -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - invalid option value: (option: "scale"; value: None) - %s. - <literal_block xml:space="preserve"> - .. image:: picture.png - :scale: -""" % DocutilsTestSupport.exception_args('int(None)')[0]], -["""\ -.. image:: picture.png - :scale 50 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - invalid option block. - <literal_block xml:space="preserve"> - .. image:: picture.png - :scale 50 -"""], -["""\ -.. image:: picture.png - scale: 50 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Image URI contains whitespace. - <literal_block xml:space="preserve"> - .. image:: picture.png - scale: 50 -"""], -["""\ -.. image:: picture.png - :: 50 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - invalid option block. - <literal_block xml:space="preserve"> - .. image:: picture.png - :: 50 -"""], -["""\ -.. image:: picture.png - :sale: 50 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - unknown option: "sale". - <literal_block xml:space="preserve"> - .. image:: picture.png - :sale: 50 -"""], -["""\ -.. image:: picture.png - :scale is: 50 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - invalid option data: extension option field name may not contain multiple words. - <literal_block xml:space="preserve"> - .. image:: picture.png - :scale is: 50 -"""], -["""\ -.. image:: picture.png - :scale: fifty -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - invalid option value: (option: "scale"; value: 'fifty') - invalid literal for int(): fifty. - <literal_block xml:space="preserve"> - .. image:: picture.png - :scale: fifty -"""], -["""\ -.. image:: picture.png - :scale: 50 - :scale: 50 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - invalid option data: duplicate option "scale". - <literal_block xml:space="preserve"> - .. 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_include.py b/docutils/test/test_parsers/test_rst/test_directives/test_include.py deleted file mode 100755 index 892ec9816..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_include.py +++ /dev/null @@ -1,309 +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 "include" directive. -""" - -import os.path -from __init__ import DocutilsTestSupport - - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -mydir = os.path.dirname(suite.func_code.co_filename) -include1 = os.path.join(mydir, 'include1.txt') -include1rel = DocutilsTestSupport.utils.relative_path(None, include1) -include2 = os.path.join(mydir, 'include2.txt') -include3 = os.path.join(mydir, 'include3.txt') -include8 = os.path.join(mydir, 'include8.txt') -include9 = os.path.join(mydir, 'include9.txt') -include9rel = DocutilsTestSupport.utils.relative_path(None, include9) - - -totest = {} - -totest['include'] = [ -["""\ -Include Test -============ - -.. include:: %s - -A paragraph. -""" % include1, -"""\ -<document source="test data"> - <section id="include-test" name="include test"> - <title> - Include Test - <section id="inclusion-1" name="inclusion 1"> - <title> - Inclusion 1 - <paragraph> - This file is used by \n\ - <literal> - test_include.py - . - <paragraph> - A paragraph. -"""], -["""\ -Include Test -============ - -.. include:: %s - :literal: - -A paragraph. -""" % include1, -"""\ -<document source="test data"> - <section id="include-test" name="include test"> - <title> - Include Test - <literal_block source="%s" xml:space="preserve"> - Inclusion 1 - ----------- - \n\ - This file is used by ``test_include.py``. - <paragraph> - A paragraph. -""" % include1rel], -["""\ -Let's test the parse context. - - This paragraph is in a block quote. - - .. include:: %s - -The included paragraphs should also be in the block quote. -""" % include2, -"""\ -<document source="test data"> - <paragraph> - Let's test the parse context. - <block_quote> - <paragraph> - This paragraph is in a block quote. - <paragraph> - Here are some paragraphs - that can appear at any level. - <paragraph> - This file (include2.txt) is used by \n\ - <literal> - test_include.py - . - <paragraph> - The included paragraphs should also be in the block quote. -"""], -["""\ -Include Test -============ - -.. include:: nonexistent.txt - -A paragraph. -""", -"""\ -<document source="test data"> - <section id="include-test" name="include test"> - <title> - Include Test - <system_message level="4" line="4" source="test data" type="SEVERE"> - <paragraph> - Problems with "include" directive path: - [Errno 2] No such file or directory: 'nonexistent.txt'. - <literal_block xml:space="preserve"> - .. include:: nonexistent.txt - <paragraph> - A paragraph. -"""], -["""\ -Include Test -============ - -.. include:: %s - -.. include:: %s - -A paragraph. -""" % (include1, include1), -"""\ -<document source="test data"> - <section id="include-test" name="include test"> - <title> - Include Test - <section dupname="inclusion 1" id="inclusion-1"> - <title> - Inclusion 1 - <paragraph> - This file is used by - <literal> - test_include.py - . - <section dupname="inclusion 1" id="id1"> - <title> - Inclusion 1 - <system_message backrefs="id1" level="1" line="2" source="%s" type="INFO"> - <paragraph> - Duplicate implicit target name: "inclusion 1". - <paragraph> - This file is used by - <literal> - test_include.py - . - <paragraph> - A paragraph. -""" % include1rel], -["""\ -Include Test -============ - -.. include:: %s - ----------- - -.. include:: %s - -A paragraph. -""" % (include1, include1), -"""\ -<document source="test data"> - <section id="include-test" name="include test"> - <title> - Include Test - <section dupname="inclusion 1" id="inclusion-1"> - <title> - Inclusion 1 - <paragraph> - This file is used by - <literal> - test_include.py - . - <transition> - <system_message level="3" line="12" source="test data" type="ERROR"> - <paragraph> - Section may not end with a transition. - <section dupname="inclusion 1" id="id1"> - <title> - Inclusion 1 - <system_message backrefs="id1" level="1" line="2" source="%s" type="INFO"> - <paragraph> - Duplicate implicit target name: "inclusion 1". - <paragraph> - This file is used by - <literal> - test_include.py - . - <paragraph> - A paragraph. -""" % include1rel], -["""\ -In test data - -.. include:: %s -""" % include3, -"""\ -<document source="test data"> - <paragraph> - In test data - <paragraph> - In include3.txt - <paragraph> - In includes/include4.txt - <paragraph> - In includes/include5.txt - <paragraph> - In includes/more/include6.txt - <paragraph> - In includes/sibling/include7.txt -"""], -["""\ -In test data - -Section -======= - -(Section contents in nested parse; slice of input_lines ViewList.) - -.. include:: %s -""" % include3, -"""\ -<document source="test data"> - <paragraph> - In test data - <section id="section" name="section"> - <title> - Section - <paragraph> - (Section contents in nested parse; slice of input_lines ViewList.) - <paragraph> - In include3.txt - <paragraph> - In includes/include4.txt - <paragraph> - In includes/include5.txt - <paragraph> - In includes/more/include6.txt - <paragraph> - In includes/sibling/include7.txt -"""], -["""\ -Testing relative includes: - -.. include:: %s -""" % include8, -"""\ -<document source="test data"> - <paragraph> - Testing relative includes: - <paragraph> - In include8.txt - <paragraph> - In ../includes/include9.txt. - <paragraph> - Here are some paragraphs - that can appear at any level. - <paragraph> - This file (include2.txt) is used by - <literal> - test_include.py - . -"""], -# @@@ BUG with errors reported with incorrect "source" & "line": -# ["""\ -# Testing bad charent includes: -# -# .. include:: %s -# """ % include9, -# """\ -# <document source="test data"> -# <paragraph> -# Testing bad charent includes: -# <system_message level="3" line="1" source="%s" type="ERROR"> -# <paragraph> -# Invalid character code: 0xFFFFFFFFF -# int() literal too large: FFFFFFFFF -# <literal_block xml:space="preserve"> -# unicode:: 0xFFFFFFFFF -# <system_message level="2" line="1" source="%s" type="WARNING"> -# <paragraph> -# Substitution definition "bad" empty or invalid. -# <literal_block xml:space="preserve"> -# .. |bad| unicode:: 0xFFFFFFFFF -# """ % (include9rel, include9rel)], -] - - -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 ecfedd721..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_meta.py +++ /dev/null @@ -1,232 +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 source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="The reStructuredText plaintext markup language" name="description"> - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="plaintext,markup language" name="keywords"> -"""], -["""\ -.. meta:: - :description lang=en: An amusing story - :description lang=fr: Un histoire amusant -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="An amusing story" lang="en" name="description"> - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="Un histoire amusant" lang="fr" name="description"> -"""], -["""\ -.. meta:: - :http-equiv=Content-Type: text/html; charset=ISO-8859-1 -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> -"""], -["""\ -.. meta:: - :name: content - over multiple lines -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="content over multiple lines" name="name"> -"""], -["""\ -Paragraph - -.. meta:: - :name: content -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="content" name="name"> -"""], -["""\ -.. meta:: -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Empty meta directive. - <literal_block xml:space="preserve"> - .. meta:: -"""], -["""\ -.. meta:: - :empty: -""", -"""\ -<document source="test data"> - <system_message level="1" line="2" source="test data" type="INFO"> - <paragraph> - No content for meta tag "empty". - <literal_block xml:space="preserve"> - :empty: -"""], -["""\ -.. meta:: - not a field list -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Invalid meta directive. - <literal_block xml:space="preserve"> - .. meta:: - not a field list -"""], -["""\ -.. meta:: - :name: content - not a field - :name: content -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="content" name="name"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Invalid meta directive. - <literal_block xml:space="preserve"> - .. meta:: - :name: content - not a field - :name: content -"""], -["""\ -.. meta:: - :name: content - :name: content - not a field -""", -"""\ -<document source="test data"> - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="content" name="name"> - <pending> - .. internal attributes: - .transform: docutils.transforms.components.Filter - .details: - component: 'writer' - format: 'html' - nodes: - <meta content="content" name="name"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Invalid meta directive. - <literal_block xml:space="preserve"> - .. meta:: - :name: content - :name: content - not a field -"""], -["""\ -.. meta:: - :name notattval: content -""", -"""\ -<document source="test data"> - <system_message level="3" line="2" source="test data" type="ERROR"> - <paragraph> - Error parsing meta tag attribute "notattval": missing "=". - <literal_block xml:space="preserve"> - :name notattval: content -"""], -] - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_raw.py b/docutils/test/test_parsers/test_rst/test_directives/test_raw.py deleted file mode 100755 index cbce2f50d..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_raw.py +++ /dev/null @@ -1,84 +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 "raw" directive. -""" - -import os.path -from __init__ import DocutilsTestSupport - - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -mydir = os.path.dirname(suite.func_code.co_filename) -raw1 = os.path.join(mydir, 'raw1.txt') - -totest = {} - -totest['raw'] = [ -["""\ -.. raw:: html - - <span>This is some plain old raw text.</span> -""", -"""\ -<document source="test data"> - <raw format="html" xml:space="preserve"> - <span>This is some plain old raw text.</span> -"""], -["""\ -.. raw:: html - :file: %s -""" % raw1, -"""\ -<document source="test data"> - <raw format="html" source="%s" xml:space="preserve"> - <p>This file is used by <tt>test_raw.py</tt>.</p> -""" % DocutilsTestSupport.utils.relative_path(None, raw1)], -["""\ -.. raw:: html - :file: rawfile.html - :url: http://example.org/ -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - The "file" and "url" options may not be simultaneously specified for the "raw" directive. - <literal_block xml:space="preserve"> - .. raw:: html - :file: rawfile.html - :url: http://example.org/ -"""], -["""\ -.. raw:: html - :file: rawfile.html - - <p>Can't have both content and file attribute.</p> -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - "raw" directive may not both specify an external file and have content. - <literal_block xml:space="preserve"> - .. raw:: html - :file: rawfile.html - - <p>Can't have both content and file attribute.</p> -"""], -] - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_replace.py b/docutils/test/test_parsers/test_rst/test_directives/test_replace.py deleted file mode 100755 index 6de59d3a4..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_replace.py +++ /dev/null @@ -1,135 +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 "replace" directive. -""" - -from __init__ import DocutilsTestSupport - - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['replace'] = [ -["""\ -Test the |name| directive. - -.. |name| replace:: "**replace**" -""", -"""\ -<document source="test data"> - <paragraph> - Test the \n\ - <substitution_reference refname="name"> - name - directive. - <substitution_definition name="name"> - " - <strong> - replace - " -"""], -["""\ -.. |name| replace:: paragraph 1 - - paragraph 2 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "replace" directive: may contain a single paragraph only. - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Substitution definition "name" empty or invalid. - <literal_block xml:space="preserve"> - .. |name| replace:: paragraph 1 - - paragraph 2 -"""], -["""\ -.. |name| replace:: -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - The "replace" directive is empty; content required. - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Substitution definition "name" empty or invalid. - <literal_block xml:space="preserve"> - .. |name| replace:: -"""], -["""\ -.. |Python| replace:: Python, *the* best language around - -.. _Python: http://www.python.org/ - -I recommend you try |Python|_. -""", -"""\ -<document source="test data"> - <substitution_definition name="Python"> - Python, - <emphasis> - the - best language around - <target id="python" name="python" refuri="http://www.python.org/"> - <paragraph> - I recommend you try - <reference refname="python"> - <substitution_reference refname="Python"> - Python - . -"""], -["""\ -.. |name| replace:: *error in **inline ``markup -""", -"""\ -<document source="test data"> - <system_message id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline emphasis start-string without end-string. - <system_message id="id3" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline strong start-string without end-string. - <system_message id="id5" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline literal start-string without end-string. - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "replace" directive: may contain a single paragraph only. - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Substitution definition "name" empty or invalid. - <literal_block xml:space="preserve"> - .. |name| replace:: *error in **inline ``markup -"""], -["""\ -.. replace:: not valid outside of a substitution definition -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Invalid context: the "replace" directive can only be used within a substitution definition. - <literal_block xml:space="preserve"> - .. replace:: not valid outside of a substitution definition -"""], -] - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_rubrics.py b/docutils/test/test_parsers/test_rst/test_directives/test_rubrics.py deleted file mode 100755 index 271802736..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_rubrics.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 the "rubric" directive. -""" - -from __init__ import DocutilsTestSupport - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['rubrics'] = [ -["""\ -.. rubric:: This is a rubric -""", -"""\ -<document source="test data"> - <rubric> - This is a rubric -"""], -["""\ -.. rubric:: -.. rubric:: A rubric has no content - - Invalid content -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "rubric" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - .. rubric:: - <system_message level="3" line="2" source="test data" type="ERROR"> - <paragraph> - Error in "rubric" directive: - no content permitted. - <literal_block xml:space="preserve"> - .. rubric:: A rubric has no content - \n\ - Invalid content -"""], -["""\ -.. rubric:: A rubric followed by a block quote -.. - - Block quote -""", -"""\ -<document source="test data"> - <rubric> - A rubric followed by a block quote - <comment xml:space="preserve"> - <block_quote> - <paragraph> - Block quote -"""], -] - - -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 09313e32b..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_test_directives.py +++ /dev/null @@ -1,195 +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 source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=[], options={}, content: None - <paragraph> - Paragraph. -"""], -["""\ -.. reStructuredText-test-directive :: - -An optional space before the "::". -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=[], options={}, content: None - <paragraph> - An optional space before the "::". -"""], -["""\ -.. reStructuredText-test-directive:: argument - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=['argument'], options={}, content: None - <paragraph> - Paragraph. -"""], -["""\ -.. reStructuredText-test-directive:: argument - :option: value - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=['argument'], options={'option': 'value'}, content: None - <paragraph> - Paragraph. -"""], -["""\ -.. reStructuredText-test-directive:: :option: value - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=[], options={'option': 'value'}, content: None - <paragraph> - Paragraph. -"""], -["""\ -.. reStructuredText-test-directive:: :option: - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "reStructuredText-test-directive" directive: - invalid option value: (option: "option"; value: None) - argument required but none supplied. - <literal_block xml:space="preserve"> - .. reStructuredText-test-directive:: :option: - <paragraph> - Paragraph. -"""], -["""\ -.. reStructuredText-test-directive:: - - Directive block contains one paragraph, with a blank line before. - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=[], options={}, content: - <literal_block xml:space="preserve"> - Directive block contains one paragraph, with a blank line before. - <paragraph> - Paragraph. -"""], -["""\ -.. reStructuredText-test-directive:: - - - Directive block contains one paragraph, with two blank lines before. - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=[], options={}, content: - <literal_block xml:space="preserve"> - Directive block contains one paragraph, with two blank lines before. - <paragraph> - Paragraph. -"""], -["""\ -.. reStructuredText-test-directive:: - Directive block contains one paragraph, no blank line before. - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=['Directive block contains one paragraph, no blank line before.'], options={}, content: None - <paragraph> - Paragraph. -"""], -["""\ -.. reStructuredText-test-directive:: - block -no blank line. - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=['block'], options={}, content: None - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <paragraph> - no blank line. - <paragraph> - Paragraph. -"""], -["""\ -.. reStructuredText-test-directive:: argument - :option: * value1 - * value2 - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Directive processed. Type="reStructuredText-test-directive", arguments=['argument'], options={'option': '* value1\\n* value2'}, content: None - <paragraph> - Paragraph. -"""], -] - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_topics.py b/docutils/test/test_parsers/test_rst/test_directives/test_topics.py deleted file mode 100644 index fa3d91100..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_topics.py +++ /dev/null @@ -1,242 +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 the "topic" directive. -""" - -from __init__ import DocutilsTestSupport - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['topics'] = [ -["""\ -.. topic:: -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "topic" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - .. topic:: -"""], -["""\ -.. topic:: Title -""", -"""\ -<document source="test data"> - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Content block expected for the "topic" directive; none found. - <literal_block xml:space="preserve"> - .. topic:: Title -"""], -["""\ -.. topic:: Title - - Body. -""", -"""\ -<document source="test data"> - <topic> - <title> - Title - <paragraph> - Body. -"""], -["""\ -.. topic:: - - Title - - Body. -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "topic" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - .. topic:: - \n\ - Title - \n\ - Body. -"""], -["""\ -.. topic:: Title - Body. -""", -"""\ -<document source="test data"> - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Content block expected for the "topic" directive; none found. - <literal_block xml:space="preserve"> - .. topic:: Title - Body. -"""], -["""\ -.. topic:: - - Title - Body. -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "topic" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - .. topic:: - \n\ - Title - Body. -"""], -["""\ -.. topic:: Title - - .. topic:: Nested - - Body. -""", -"""\ -<document source="test data"> - <topic> - <title> - Title - <system_message level="3" line="3" source="test data" type="ERROR"> - <paragraph> - The "topic" directive may not be used within topics, sidebars, or body elements. - <literal_block xml:space="preserve"> - .. topic:: Nested - \n\ - Body. -"""], -["""\ -.. topic:: Title - - .. topic:: Nested - - Body. - More. -""", -"""\ -<document source="test data"> - <topic> - <title> - Title - <system_message level="3" line="3" source="test data" type="ERROR"> - <paragraph> - The "topic" directive may not be used within topics, sidebars, or body elements. - <literal_block xml:space="preserve"> - .. topic:: Nested - \n\ - Body. - <system_message level="2" line="6" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <paragraph> - More. -"""], -["""\ -.. topic:: Title - - .. topic:: Nested - - Body. - - More. - -More. -""", -"""\ -<document source="test data"> - <topic> - <title> - Title - <system_message level="3" line="3" source="test data" type="ERROR"> - <paragraph> - The "topic" directive may not be used within topics, sidebars, or body elements. - <literal_block xml:space="preserve"> - .. topic:: Nested - \n\ - Body. - <paragraph> - More. - <paragraph> - More. -"""], -["""\ -.. topic:: First - - Body - -.. topic:: Second - - Body. -""", -"""\ -<document source="test data"> - <topic> - <title> - First - <paragraph> - Body - <topic> - <title> - Second - <paragraph> - Body. -"""], -["""\ -.. sidebar:: Title - :subtitle: Outer - - .. topic:: Nested - - Body. - - More. - -More. -""", -"""\ -<document source="test data"> - <sidebar> - <title> - Title - <subtitle> - Outer - <system_message level="3" line="4" source="test data" type="ERROR"> - <paragraph> - The "topic" directive may not be used within topics, sidebars, or body elements. - <literal_block xml:space="preserve"> - .. topic:: Nested - \n\ - Body. - <paragraph> - More. - <paragraph> - More. -"""], -] - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py b/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py deleted file mode 100755 index 704c13fa5..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py +++ /dev/null @@ -1,131 +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 "unicode" directive. -""" - -from __init__ import DocutilsTestSupport - - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['unicode'] = [ -[""" -Insert an em-dash (|mdash|), a copyright symbol (|copy|), a non-breaking -space (|nbsp|), a backwards-not-equals (|bne|), and a captial omega (|Omega|). - -.. |mdash| unicode:: 0x02014 -.. |copy| unicode:: \\u00A9 -.. |nbsp| unicode::   -.. |bne| unicode:: U0003D U020E5 -.. |Omega| unicode:: U+003A9 -""", -u"""\ -<document source="test data"> - <paragraph> - Insert an em-dash ( - <substitution_reference refname="mdash"> - mdash - ), a copyright symbol ( - <substitution_reference refname="copy"> - copy - ), a non-breaking - space ( - <substitution_reference refname="nbsp"> - nbsp - ), a backwards-not-equals ( - <substitution_reference refname="bne"> - bne - ), and a captial omega ( - <substitution_reference refname="Omega"> - Omega - ). - <substitution_definition name="mdash"> - \u2014 - <substitution_definition name="copy"> - \u00A9 - <substitution_definition name="nbsp"> - \u00A0 - <substitution_definition name="bne"> - = - \u20e5 - <substitution_definition name="Omega"> - \u03a9 -"""], -[""" -Bad input: - -.. |empty| unicode:: -.. |not hex| unicode:: 0xHEX -.. |not all hex| unicode:: UABCX -.. unicode:: not in a substitution definition -""", -"""\ -<document source="test data"> - <paragraph> - Bad input: - <system_message level="3" line="4" source="test data" type="ERROR"> - <paragraph> - Error in "unicode" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - unicode:: - <system_message level="2" line="4" source="test data" type="WARNING"> - <paragraph> - Substitution definition "empty" empty or invalid. - <literal_block xml:space="preserve"> - .. |empty| unicode:: - <substitution_definition name="not hex"> - 0xHEX - <substitution_definition name="not all hex"> - UABCX - <system_message level="3" line="7" source="test data" type="ERROR"> - <paragraph> - Invalid context: the "unicode" directive can only be used within a substitution definition. - <literal_block xml:space="preserve"> - .. unicode:: not in a substitution definition -"""], -[""" -Testing comments and extra text. - -Copyright |copy| 2003, |BogusMegaCorp (TM)|. - -.. |copy| unicode:: 0xA9 .. copyright sign -.. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122 - .. with trademark sign -""", -u"""\ -<document source="test data"> - <paragraph> - Testing comments and extra text. - <paragraph> - Copyright - <substitution_reference refname="copy"> - copy - 2003, - <substitution_reference refname="BogusMegaCorp (TM)"> - BogusMegaCorp (TM) - . - <substitution_definition name="copy"> - \u00A9 - <substitution_definition name="BogusMegaCorp (TM)"> - BogusMegaCorp - \u2122 -"""], -] - - -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 3c859faa3..000000000 --- a/docutils/test/test_parsers/test_rst/test_directives/test_unknown.py +++ /dev/null @@ -1,67 +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 source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - No directive entry for "reStructuredText-unknown-directive" in module "docutils.parsers.rst.languages.en". - Trying "reStructuredText-unknown-directive" as canonical directive name. - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Unknown directive type "reStructuredText-unknown-directive". - <literal_block xml:space="preserve"> - .. reStructuredText-unknown-directive:: - <system_message level="1" line="3" source="test data" type="INFO"> - <paragraph> - No directive entry for "reStructuredText-unknown-directive" in module "docutils.parsers.rst.languages.en". - Trying "reStructuredText-unknown-directive" as canonical directive name. - <system_message level="3" line="3" source="test data" type="ERROR"> - <paragraph> - Unknown directive type "reStructuredText-unknown-directive". - <literal_block xml:space="preserve"> - .. reStructuredText-unknown-directive:: argument - <system_message level="1" line="5" source="test data" type="INFO"> - <paragraph> - No directive entry for "reStructuredText-unknown-directive" in module "docutils.parsers.rst.languages.en". - Trying "reStructuredText-unknown-directive" as canonical directive name. - <system_message level="3" line="5" source="test data" type="ERROR"> - <paragraph> - Unknown directive type "reStructuredText-unknown-directive". - <literal_block xml:space="preserve"> - .. 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 c9637c6d6..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 source="test data"> - <paragraph> - Paragraph. - <doctest_block xml:space="preserve"> - >>> print "Doctest block." - Doctest block. - <paragraph> - Paragraph. -"""], -["""\ -Paragraph. - ->>> print " Indented output." - Indented output. -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph. - <doctest_block xml:space="preserve"> - >>> print " Indented output." - Indented output. -"""], -["""\ -Paragraph. - - >>> print " Indented block & output." - Indented block & output. -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph. - <block_quote> - <doctest_block xml:space="preserve"> - >>> 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 b89691516..000000000 --- a/docutils/test/test_parsers/test_rst/test_enumerated_lists.py +++ /dev/null @@ -1,727 +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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <paragraph> - 1. - empty item above, no blank line -"""], -["""\ -Scrambled: - -3. Item three. - -2. Item two. - -1. Item one. - -3. Item three. -2. Item two. -1. Item one. -""", -"""\ -<document source="test data"> - <paragraph> - Scrambled: - <system_message level="1" line="3" source="test data" type="INFO"> - <paragraph> - Enumerated list start value not ordinal-1: "3" (ordinal 3) - <enumerated_list enumtype="arabic" prefix="" start="3" suffix="."> - <list_item> - <paragraph> - Item three. - <system_message level="1" line="5" source="test data" type="INFO"> - <paragraph> - Enumerated list start value not ordinal-1: "2" (ordinal 2) - <enumerated_list enumtype="arabic" prefix="" start="2" suffix="."> - <list_item> - <paragraph> - Item two. - <enumerated_list enumtype="arabic" prefix="" suffix="."> - <list_item> - <paragraph> - Item one. - <paragraph> - 3. Item three. - 2. Item two. - 1. Item one. -"""], -["""\ -Skipping item 3: - -1. Item 1. -2. Item 2. -4. Item 4. -""", -"""\ -<document source="test data"> - <paragraph> - Skipping item 3: - <enumerated_list enumtype="arabic" prefix="" suffix="."> - <list_item> - <paragraph> - Item 1. - <system_message level="2" line="4" source="test data" type="WARNING"> - <paragraph> - Enumerated list ends without a blank line; unexpected unindent. - <paragraph> - 2. Item 2. - 4. 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 source="test data"> - <paragraph> - Start with non-ordinal-1: - <system_message level="1" line="3" source="test data" type="INFO"> - <paragraph> - Enumerated list start value not ordinal-1: "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" line="10" source="test data" type="INFO"> - <paragraph> - Enumerated list start value not ordinal-1: "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 source="test data"> - <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 source="test data"> - <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 - second line - -(LCD) is an acronym made up of Roman numerals - -(livid) is a word made up of Roman numerals - -(CIVIL) is another such word - -(I) I - -(IVXLCDM) IVXLCDM -""", -"""\ -<document source="test data"> - <paragraph> - Bad Roman numerals: - <enumerated_list enumtype="lowerroman" prefix="" suffix="."> - <list_item> - <paragraph> - i - <list_item> - <paragraph> - ii - <list_item> - <paragraph> - iii - <definition_list> - <definition_list_item> - <term> - iiii. iiii - <definition> - <paragraph> - second line - <paragraph> - (LCD) is an acronym made up of Roman numerals - <paragraph> - (livid) is a word made up of Roman numerals - <paragraph> - (CIVIL) is another such word - <enumerated_list enumtype="upperroman" prefix="(" suffix=")"> - <list_item> - <paragraph> - I - <paragraph> - (IVXLCDM) 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 source="test data"> - <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 source="test data"> - <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. - <system_message level="2" line="11" source="test data" type="WARNING"> - <paragraph> - Enumerated list ends without a blank line; unexpected unindent. - <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. - <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. - <system_message level="2" line="23" source="test data" type="WARNING"> - <paragraph> - Enumerated list ends without a blank line; unexpected unindent. - <enumerated_list enumtype="lowerroman" prefix="" suffix="."> - <list_item> - <paragraph> - Item i. - <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 source="test data"> - <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 source="test data"> - <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. -"""], -["""\ -A. Einstein was a great influence on -B. Physicist, who was a colleague of -C. Chemist. They all worked in -Princeton, NJ. -""", -# @@@ I think this is the correct result, but I'm not certain: -"""\ -<document source="test data"> - <enumerated_list enumtype="upperalpha" prefix="" suffix="."> - <list_item> - <paragraph> - Einstein was a great influence on - <list_item> - <paragraph> - Physicist, who was a colleague of - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Enumerated list ends without a blank line; unexpected unindent. - <paragraph> - C. Chemist. They all worked in - Princeton, NJ. -"""], -["""\ -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 source="test data"> - <enumerated_list enumtype="arabic" prefix="" suffix="."> - <list_item> - <paragraph> - Item one: line 1, - line 2. - <list_item> - <paragraph> - Item two: line 1, - <system_message level="2" line="4" source="test data" type="WARNING"> - <paragraph> - Enumerated list ends without a blank line; unexpected unindent. - <block_quote> - <paragraph> - line 2. - <system_message level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Block quote ends without a blank line; unexpected unindent. - <system_message level="1" line="5" source="test data" type="INFO"> - <paragraph> - Enumerated list start value not ordinal-1: "3" (ordinal 3) - <enumerated_list enumtype="arabic" prefix="" start="3" suffix="."> - <list_item> - <paragraph> - Item three: paragraph 1, line 1, - <system_message level="2" line="6" source="test data" type="WARNING"> - <paragraph> - Enumerated list ends without a blank line; unexpected unindent. - <block_quote> - <paragraph> - line 2. - <block_quote> - <paragraph> - Paragraph 2. -"""], -] - - -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 4bdf07527..000000000 --- a/docutils/test/test_parsers/test_rst/test_field_lists.py +++ /dev/null @@ -1,469 +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 source="test data"> - <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 i - <field_body> - <paragraph> - integer -"""], -["""\ -One-liners, no blank lines: - -:Author: Me -:Version: 1 -:Date: 2001-08-11 -:Parameter i: integer -""", -"""\ -<document source="test data"> - <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 i - <field_body> - <paragraph> - integer -"""], -["""\ -:field: -empty item above, no blank line -""", -"""\ -<document source="test data"> - <field_list> - <field> - <field_name> - field - <field_body> - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Field list ends without a blank line; unexpected unindent. - <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 source="test data"> - <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 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 source="test data"> - <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 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 source="test data"> - <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 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 source="test data"> - <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 xml:space="preserve"> - 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 source="test data"> - <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 source="test data"> - <field_list> - <field> - <field_name> - Parameter i j 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 source="test data"> - <paragraph> - Some edge cases: - <field_list> - <field> - <field_name> - Empty - <field_body> - <field> - <field_name> - Author - <field_body> - <paragraph> - Me - <system_message level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Field list ends without a blank line; unexpected unindent. - <paragraph> - No blank line before this paragraph. - <field_list> - <field> - <field_name> - *Field* `with` **inline** ``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 00e5c1f5d..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 source="test data"> - <footnote id="id1" name="1"> - <label> - 1 - <paragraph> - This is a footnote. -"""], -["""\ -.. [1] This is a footnote - on multiple lines. -""", -"""\ -<document source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <footnote id="id1" name="1"> - <label> - 1 - <paragraph> - That was an empty footnote. -"""], -["""\ -.. [1] -No blank line. -""", -"""\ -<document source="test data"> - <footnote id="id1" name="1"> - <label> - 1 - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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" line="12" source="test data" 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 source="test data"> - <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" line="14" source="test data" 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 source="test data"> - <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 e6694b2c5..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 2cafdb09a..000000000 --- a/docutils/test/test_parsers/test_rst/test_inline_markup.py +++ /dev/null @@ -1,851 +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 inline markup in docutils/parsers/rst/states.py. -Interpreted text tests are in a separate module, test_interpreted.py. -""" - -from __init__ import DocutilsTestSupport - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['emphasis'] = [ -["""\ -*emphasis* -""", -"""\ -<document source="test data"> - <paragraph> - <emphasis> - emphasis -"""], -["""\ -*emphasized sentence -across lines* -""", -"""\ -<document source="test data"> - <paragraph> - <emphasis> - emphasized sentence - across lines -"""], -["""\ -*emphasis without closing asterisk -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - * - emphasis without closing asterisk - <system_message backrefs="id2" id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline emphasis start-string without end-string. -"""], -["""\ -'*emphasis*' and 1/*emphasis*/2 and 3-*emphasis*-4 and 5:*emphasis*:6 -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 source="test data"> - <paragraph> - ' - <emphasis> - emphasis - ' and 1/ - <emphasis> - emphasis - /2 and 3- - <emphasis> - emphasis - -4 and 5: - <emphasis> - emphasis - :6 - 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" line="5" source="test data" type="WARNING"> - <paragraph> - Inline emphasis start-string without end-string. - <paragraph> - what about \n\ - <emphasis> - this* - ? -"""], -["""\ -Emphasized asterisk: *\\** - -Emphasized double asterisk: *\\*** -""", -"""\ -<document source="test data"> - <paragraph> - Emphasized asterisk: \n\ - <emphasis> - * - <paragraph> - Emphasized double asterisk: \n\ - <emphasis> - ** -"""], -] - -totest['strong'] = [ -["""\ -**strong** -""", -"""\ -<document source="test data"> - <paragraph> - <strong> - strong -"""], -["""\ -(**strong**) but not (**) or '(** ' or x**2 or \\**kwargs or ** - -(however, '**kwargs' will trigger a warning and may be problematic) -""", -"""\ -<document source="test data"> - <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" line="3" source="test data" type="WARNING"> - <paragraph> - Inline strong start-string without end-string. -"""], -["""\ -Strong asterisk: ***** - -Strong double asterisk: ****** -""", -"""\ -<document source="test data"> - <paragraph> - Strong asterisk: \n\ - <strong> - * - <paragraph> - Strong double asterisk: \n\ - <strong> - ** -"""], -["""\ -**strong without closing asterisks -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - ** - strong without closing asterisks - <system_message backrefs="id2" id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline strong start-string without end-string. -"""], -] - -totest['literal'] = [ -["""\ -``literal`` -""", -"""\ -<document source="test data"> - <paragraph> - <literal> - literal -"""], -["""\ -``\\literal`` -""", -"""\ -<document source="test data"> - <paragraph> - <literal> - \\literal -"""], -["""\ -``lite\\ral`` -""", -"""\ -<document source="test data"> - <paragraph> - <literal> - lite\\ral -"""], -["""\ -``literal\\`` -""", -"""\ -<document source="test data"> - <paragraph> - <literal> - literal\\ -"""], -["""\ -``literal ``TeX quotes'' & \\backslash`` but not "``" or `` - -(however, ``standalone TeX quotes'' will trigger a warning -and may be problematic) -""", -"""\ -<document source="test data"> - <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" line="3" source="test data" type="WARNING"> - <paragraph> - Inline literal start-string without end-string. -"""], -["""\ -Find the ```interpreted text``` in this paragraph! -""", -"""\ -<document source="test data"> - <paragraph> - Find the \n\ - <literal> - `interpreted text` - in this paragraph! -"""], -["""\ -``literal without closing backquotes -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - `` - literal without closing backquotes - <system_message backrefs="id2" id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline literal start-string without end-string. -"""], -["""\ -Python ``list``\\s use square bracket syntax. -""", -"""\ -<document source="test data"> - <paragraph> - Python \n\ - <literal> - list - s use square bracket syntax. -"""], -] - -totest['references'] = [ -["""\ -ref_ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refname="ref"> - ref -"""], -["""\ -ref__ -""", -"""\ -<document source="test data"> - <paragraph> - <reference anonymous="1"> - ref -"""], -["""\ -ref_, r_, r_e-f_, -ref_, and anonymousref__, -but not _ref_ or __attr__ or object.__attr__ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refname="ref"> - ref - , \n\ - <reference refname="r"> - r - , \n\ - <reference refname="r_e-f"> - r_e-f - , - - <reference refname="ref"> - ref - , and \n\ - <reference anonymous="1"> - anonymousref - , - but not _ref_ or __attr__ or object.__attr__ -"""], -] - -totest['phrase_references'] = [ -["""\ -`phrase reference`_ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refname="phrase reference"> - phrase reference -"""], -["""\ -`anonymous reference`__ -""", -"""\ -<document source="test data"> - <paragraph> - <reference anonymous="1"> - anonymous reference -"""], -["""\ -`phrase reference -across lines`_ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refname="phrase reference across lines"> - phrase reference - across lines -"""], -["""\ -`phrase\`_ reference`_ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refname="phrase`_ reference"> - phrase`_ reference -"""], -["""\ -Invalid phrase reference: - -:role:`phrase reference`_ -""", -"""\ -<document source="test data"> - <paragraph> - Invalid phrase reference: - <paragraph> - <problematic id="id2" refid="id1"> - :role:`phrase reference`_ - <system_message backrefs="id2" id="id1" level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Mismatch: both interpreted text role prefix and reference suffix. -"""], -["""\ -Invalid phrase reference: - -`phrase reference`:role:_ -""", -"""\ -<document source="test data"> - <paragraph> - Invalid phrase reference: - <paragraph> - <problematic id="id2" refid="id1"> - `phrase reference`:role:_ - <system_message backrefs="id2" id="id1" level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Mismatch: both interpreted text role suffix and reference suffix. -"""], -["""\ -`phrase reference_ without closing backquote -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - ` - phrase \n\ - <reference refname="reference"> - reference - without closing backquote - <system_message backrefs="id2" id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline interpreted text or phrase reference start-string without end-string. -"""], -["""\ -`anonymous phrase reference__ without closing backquote -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - ` - anonymous phrase \n\ - <reference anonymous="1"> - reference - without closing backquote - <system_message backrefs="id2" id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline interpreted text or phrase reference start-string without end-string. -"""], -] - -totest['embedded_URIs'] = [ -["""\ -`phrase reference <http://example.com>`_ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://example.com"> - phrase reference - <target id="phrase-reference" name="phrase reference" refuri="http://example.com"> -"""], -["""\ -`anonymous reference <http://example.com>`__ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://example.com"> - anonymous reference -"""], -["""\ -`embedded URI on next line -<http://example.com>`__ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://example.com"> - embedded URI on next line -"""], -["""\ -`embedded URI across lines <http://example.com/ -long/path>`__ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://example.com/long/path"> - embedded URI across lines -"""], -["""\ -`embedded URI with whitespace <http://example.com/ -long/path /and /whitespace>`__ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://example.com/long/path/and/whitespace"> - embedded URI with whitespace -"""], -["""\ -`embedded email address <jdoe@example.com>`__ - -`embedded email address broken across lines <jdoe -@example.com>`__ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="mailto:jdoe@example.com"> - embedded email address - <paragraph> - <reference refuri="mailto:jdoe@example.com"> - embedded email address broken across lines -"""], -["""\ -`embedded URI with too much whitespace < http://example.com/ -long/path /and /whitespace >`__ - -`embedded URI with too much whitespace at end <http://example.com/ -long/path /and /whitespace >`__ - -`embedded URI with no preceding whitespace<http://example.com>`__ - -`escaped URI \\<http://example.com>`__ - -See `HTML Anchors: \\<a>`_. -""", -"""\ -<document source="test data"> - <paragraph> - <reference anonymous="1"> - embedded URI with too much whitespace < http://example.com/ - long/path /and /whitespace > - <paragraph> - <reference anonymous="1"> - embedded URI with too much whitespace at end <http://example.com/ - long/path /and /whitespace > - <paragraph> - <reference anonymous="1"> - embedded URI with no preceding whitespace<http://example.com> - <paragraph> - <reference anonymous="1"> - escaped URI <http://example.com> - <paragraph> - See \n\ - <reference refname="html anchors: <a>"> - HTML Anchors: <a> - . -"""], -] - -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 source="test data"> - <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 source="test data"> - <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" line="3" source="test data" type="WARNING"> - <paragraph> - Inline target start-string without end-string. -"""], -["""\ -_`inline target without closing backquote -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - _` - inline target without closing backquote - <system_message backrefs="id2" id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline target start-string without end-string. -"""], -] - -totest['footnote_reference'] = [ -["""\ -[1]_ -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference id="id1" refname="1"> - 1 -"""], -["""\ -[#]_ -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference auto="1" id="id1"> -"""], -["""\ -[#label]_ -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference auto="1" id="id1" refname="label"> -"""], -["""\ -[*]_ -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference auto="*" id="id1"> -"""], -] - -totest['citation_reference'] = [ -["""\ -[citation]_ -""", -"""\ -<document source="test data"> - <paragraph> - <citation_reference id="id1" refname="citation"> - citation -"""], -["""\ -[citation]_ and [cit-ation]_ and [cit.ation]_ and [CIT1]_ but not [CIT 1]_ -""", -"""\ -<document source="test data"> - <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 source="test data"> - <paragraph> - <substitution_reference refname="subref"> - subref -"""], -["""\ -|subref|_ and |subref|__ -""", -"""\ -<document source="test data"> - <paragraph> - <reference refname="subref"> - <substitution_reference refname="subref"> - subref - and \n\ - <reference anonymous="1"> - <substitution_reference refname="subref"> - subref -"""], -["""\ -|substitution reference| -""", -"""\ -<document source="test data"> - <paragraph> - <substitution_reference refname="substitution reference"> - substitution reference -"""], -["""\ -|substitution -reference| -""", -"""\ -<document source="test data"> - <paragraph> - <substitution_reference refname="substitution reference"> - substitution - reference -"""], -["""\ -|substitution reference without closing verbar -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - | - substitution reference without closing verbar - <system_message backrefs="id2" id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline substitution_reference start-string without end-string. -"""], -["""\ -| and || and ||| -""", -"""\ -<document source="test data"> - <paragraph> - | and || and ||| -"""], -] - -totest['standalone_hyperlink'] = [ -["""\ -http://www.standalone.hyperlink.com - -http:/one-slash-only.absolute.path - -[http://example.com] - -(http://example.com) - -<http://example.com> - -http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html - -http://[3ffe:2a00:100:7031::1] (the final "]" is ambiguous in text) - -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 source="test data"> - <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://example.com"> - http://example.com - ] - <paragraph> - ( - <reference refuri="http://example.com"> - http://example.com - ) - <paragraph> - < - <reference refuri="http://example.com"> - http://example.com - > - <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 - ] (the final "]" is ambiguous in text) - <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 source="test data"> - <paragraph> - None of these are standalone hyperlinks (their "schemes" - are not recognized): signal:noise, a:b. -"""], -] - -totest['miscellaneous'] = [ -["""\ -__This__ should be left alone. -""", -"""\ -<document source="test data"> - <paragraph> - __This__ should be left alone. -"""], -[r""" -Character-level m\ *a*\ **r**\ ``k``\ `u`:title:\p -with backslash-escaped whitespace, including new\ -lines. -""", -"""\ -<document source="test data"> - <paragraph> - Character-level m - <emphasis> - a - <strong> - r - <literal> - k - <title_reference> - u - p - with backslash-escaped whitespace, including newlines. -"""], -] - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_parsers/test_rst/test_interpreted.py b/docutils/test/test_parsers/test_rst/test_interpreted.py deleted file mode 100644 index 6c0d30ac0..000000000 --- a/docutils/test/test_parsers/test_rst/test_interpreted.py +++ /dev/null @@ -1,305 +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 interpreted text in docutils/parsers/rst/states.py. -""" - -from __init__ import DocutilsTestSupport - -def suite(): - s = DocutilsTestSupport.ParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['basics'] = [ -["""\ -`interpreted` -""", -"""\ -<document source="test data"> - <paragraph> - <title_reference> - interpreted -"""], -["""\ -:title:`interpreted` -""", -"""\ -<document source="test data"> - <paragraph> - <title_reference> - interpreted -"""], -["""\ -`interpreted`:title: -""", -"""\ -<document source="test data"> - <paragraph> - <title_reference> - interpreted -"""], -["""\ -`interpreted \`title`` -""", -"""\ -<document source="test data"> - <paragraph> - <title_reference> - interpreted `title` -"""], -["""\ -:title:`:not-role: interpreted` -""", -"""\ -<document source="test data"> - <paragraph> - <title_reference> - :not-role: interpreted -"""], -["""\ -`interpreted` but not \\`interpreted` [`] or ({[`] or [`]}) or ` -""", -"""\ -<document source="test data"> - <paragraph> - <title_reference> - interpreted - but not `interpreted` [`] or ({[`] or [`]}) or ` -"""], -["""\ -`interpreted`-text `interpreted`: text `interpreted`:text `text`'s interpreted -""", -"""\ -<document source="test data"> - <paragraph> - <title_reference> - interpreted - -text \n\ - <title_reference> - interpreted - : text \n\ - <title_reference> - interpreted - :text \n\ - <title_reference> - text - 's interpreted -"""], -["""\ -`interpreted without closing backquote -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - ` - interpreted without closing backquote - <system_message backrefs="id2" id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Inline interpreted text or phrase reference start-string without end-string. -"""], -["""\ -`interpreted`:not a role if it contains whitespace: -""", -"""\ -<document source="test data"> - <paragraph> - <title_reference> - interpreted - :not a role if it contains whitespace: -"""], -["""\ -:title:`` (empty interpteted text not recognized) -""", -"""\ -<document source="test data"> - <paragraph> - :title:`` (empty interpteted text not recognized) -"""], -["""\ -Explicit roles for standard inline markup: -:emphasis:`emphasis`, -:strong:`strong`, -:literal:`inline literal text`. -""", -"""\ -<document source="test data"> - <paragraph> - Explicit roles for standard inline markup: - <emphasis> - emphasis - , - <strong> - strong - , - <literal> - inline literal text - . -"""], -["""\ -Simple explicit roles: -:ab:`abbreviation`, -:ac:`acronym`, -:sup:`superscript`, -:sub:`subscript`, -:title:`title reference`. -""", -"""\ -<document source="test data"> - <paragraph> - Simple explicit roles: - <abbreviation> - abbreviation - , - <acronym> - acronym - , - <superscript> - superscript - , - <subscript> - subscript - , - <title_reference> - title reference - . -"""], -] - -totest['references'] = [ -["""\ -:PEP:`0` -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://www.python.org/peps/pep-0000.html"> - PEP 0 -"""], -["""\ -:PEP:`-1` -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - -1 - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - PEP number must be a number from 0 to 9999; "-1" is invalid. -"""], -["""\ -:RFC:`2822` -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://www.faqs.org/rfcs/rfc2822.html"> - RFC 2822 -"""], -["""\ -:RFC:`0` -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - 0 - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - RFC number must be a number greater than or equal to 1; "0" is invalid. -"""], -] - -totest['unknown_roles'] = [ -["""\ -:role:`interpreted` -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - :role:`interpreted` - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - No role entry for "role" in module "docutils.parsers.rst.languages.en". - Trying "role" as canonical role name. - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Unknown interpreted text role "role". -"""], -["""\ -`interpreted`:role: -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - `interpreted`:role: - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - No role entry for "role" in module "docutils.parsers.rst.languages.en". - Trying "role" as canonical role name. - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Unknown interpreted text role "role". -"""], -["""\ -:role:`interpreted`:role: -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - :role:`interpreted`:role: - <system_message backrefs="id2" id="id1" level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Multiple roles in interpreted text (both prefix and suffix present; only one allowed). -"""], -["""\ -:very.long-role_name:`interpreted` -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - :very.long-role_name:`interpreted` - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - No role entry for "very.long-role_name" in module "docutils.parsers.rst.languages.en". - Trying "very.long-role_name" as canonical role name. - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Unknown interpreted text role "very.long-role_name". -"""], -["""\ -:restructuredtext-unimplemented-role:`interpreted` -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - :restructuredtext-unimplemented-role:`interpreted` - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - No role entry for "restructuredtext-unimplemented-role" in module "docutils.parsers.rst.languages.en". - Trying "restructuredtext-unimplemented-role" as canonical role name. - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Interpreted text role "restructuredtext-unimplemented-role" not implemented. -"""], -] - - -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 2fe1c9b88..000000000 --- a/docutils/test/test_parsers/test_rst/test_literal_blocks.py +++ /dev/null @@ -1,234 +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 source="test data"> - <paragraph> - A paragraph: - <literal_block xml:space="preserve"> - A literal block. -"""], -["""\ -A paragraph with a space after the colons:: \n\ - - A literal block. -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph with a space after the colons: - <literal_block xml:space="preserve"> - A literal block. -"""], -["""\ -A paragraph:: - - A literal block. - -Another paragraph:: - - Another literal block. - With two blank lines following. - - -A final paragraph. -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph: - <literal_block xml:space="preserve"> - A literal block. - <paragraph> - Another paragraph: - <literal_block xml:space="preserve"> - Another literal block. - With two blank lines following. - <paragraph> - A final paragraph. -"""], -["""\ -A paragraph -on more than -one line:: - - A literal block. -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph - on more than - one line: - <literal_block xml:space="preserve"> - A literal block. -"""], -["""\ -A paragraph -on more than -one line:: - A literal block - with no blank line above. -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph - on more than - one line: - <system_message level="3" line="4" source="test data" type="ERROR"> - <paragraph> - Unexpected indentation. - <literal_block xml:space="preserve"> - A literal block - with no blank line above. -"""], -["""\ -A paragraph:: - - A literal block. -no blank line -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph: - <literal_block xml:space="preserve"> - A literal block. - <system_message level="2" line="4" source="test data" type="WARNING"> - <paragraph> - Literal block ends without a blank line; unexpected unindent. - <paragraph> - no blank line -"""], -["""\ -A paragraph: :: - - A literal block. -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph: - <literal_block xml:space="preserve"> - A literal block. -"""], -["""\ -A paragraph: - -:: - - A literal block. -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph: - <literal_block xml:space="preserve"> - A literal block. -"""], -["""\ -A paragraph: -:: - - A literal block. -""", -"""\ -<document source="test data"> - <system_message level="1" line="2" source="test data" type="INFO"> - <paragraph> - Possible title underline, too short for the title. - Treating it as ordinary text because it's so short. - <paragraph> - A paragraph: - <literal_block xml:space="preserve"> - A literal block. -"""], -["""\ -A paragraph: - -:: - - A literal block. -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph: - <literal_block xml:space="preserve"> - A literal block. -"""], -["""\ -A paragraph:: - -Not a literal block. -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph: - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Literal block expected; none found. - <paragraph> - Not a literal block. -"""], -["""\ -A paragraph:: - - A wonky literal block. - Literal line 2. - - Literal line 3. -""", -"""\ -<document source="test data"> - <paragraph> - A paragraph: - <literal_block xml:space="preserve"> - A wonky literal block. - Literal line 2. - \n\ - Literal line 3. -"""], -["""\ -EOF, even though a literal block is indicated:: -""", -"""\ -<document source="test data"> - <paragraph> - EOF, even though a literal block is indicated: - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Literal block expected; 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 e7f17f615..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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 1522b7f30..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 source="test data"> - <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 source="test data"> - <bullet_list bullet="+"> - <list_item> - <paragraph> - bullet - <comment xml:space="preserve"> - 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 xml:space="preserve"> - <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 8ec8cbbc5..000000000 --- a/docutils/test/test_parsers/test_rst/test_paragraphs.py +++ /dev/null @@ -1,89 +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 source="test data"> - <paragraph> - A paragraph. -"""], -["""\ -Paragraph 1. - -Paragraph 2. -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph 1. - <paragraph> - Paragraph 2. -"""], -["""\ -Line 1. -Line 2. -Line 3. -""", -"""\ -<document source="test data"> - <paragraph> - Line 1. - Line 2. - Line 3. -"""], -["""\ -Paragraph 1, Line 1. -Line 2. -Line 3. - -Paragraph 2, Line 1. -Line 2. -Line 3. -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph 1, Line 1. - Line 2. - Line 3. - <paragraph> - Paragraph 2, Line 1. - Line 2. - Line 3. -"""], -["""\ -A. Einstein was a really -smart dude. -""", -"""\ -<document source="test data"> - <paragraph> - A. Einstein was a really - smart dude. -"""], -] - -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 98fdfcb8f..000000000 --- a/docutils/test/test_parsers/test_rst/test_section_headers.py +++ /dev/null @@ -1,912 +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 source="test data"> - <section id="title" name="title"> - <title> - Title - <paragraph> - Paragraph. -"""], -["""\ -Title -===== -Paragraph (no blank line). -""", -"""\ -<document source="test data"> - <section id="title" name="title"> - <title> - Title - <paragraph> - Paragraph (no blank line). -"""], -["""\ -Paragraph. - -Title -===== - -Paragraph. -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph. - <section id="title" name="title"> - <title> - Title - <paragraph> - Paragraph. -"""], -["""\ -Test unexpected section titles. - - Title - ===== - Paragraph. - - ----- - Title - ----- - Paragraph. -""", -"""\ -<document source="test data"> - <paragraph> - Test unexpected section titles. - <block_quote> - <system_message level="4" line="4" source="test data" type="SEVERE"> - <paragraph> - Unexpected section title. - <literal_block xml:space="preserve"> - Title - ===== - <paragraph> - Paragraph. - <system_message level="4" line="7" source="test data" type="SEVERE"> - <paragraph> - Unexpected section title or transition. - <literal_block xml:space="preserve"> - ----- - <system_message level="4" line="9" source="test data" type="SEVERE"> - <paragraph> - Unexpected section title. - <literal_block xml:space="preserve"> - Title - ----- - <paragraph> - Paragraph. -"""], -["""\ -Title -==== - -Test short underline. -""", -"""\ -<document source="test data"> - <section id="title" name="title"> - <title> - Title - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Title underline too short. - <literal_block xml:space="preserve"> - Title - ==== - <paragraph> - Test short underline. -"""], -["""\ -===== -Title -===== - -Test overline title. -""", -"""\ -<document source="test data"> - <section id="title" name="title"> - <title> - Title - <paragraph> - Test overline title. -"""], -["""\ -======= - Title -======= - -Test overline title with inset. -""", -"""\ -<document source="test data"> - <section id="title" name="title"> - <title> - Title - <paragraph> - Test overline title with inset. -"""], -["""\ -======================== - Test Missing Underline -""", -"""\ -<document source="test data"> - <system_message level="4" line="1" source="test data" type="SEVERE"> - <paragraph> - Incomplete section title. - <literal_block xml:space="preserve"> - ======================== - Test Missing Underline -"""], -["""\ -======================== - Test Missing Underline - -""", -"""\ -<document source="test data"> - <system_message level="4" line="1" source="test data" type="SEVERE"> - <paragraph> - Missing matching underline for section title overline. - <literal_block xml:space="preserve"> - ======================== - Test Missing Underline -"""], -["""\ -======= - Title - -Test missing underline, with paragraph. -""", -"""\ -<document source="test data"> - <system_message level="4" line="1" source="test data" type="SEVERE"> - <paragraph> - Missing matching underline for section title overline. - <literal_block xml:space="preserve"> - ======= - Title - <paragraph> - Test missing underline, with paragraph. -"""], -["""\ -======= - Long Title -======= - -Test long title and space normalization. -""", -"""\ -<document source="test data"> - <section id="long-title" name="long title"> - <title> - Long Title - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Title overline too short. - <literal_block xml:space="preserve"> - ======= - Long Title - ======= - <paragraph> - Test long title and space normalization. -"""], -["""\ -======= - Title -------- - -Paragraph. -""", -"""\ -<document source="test data"> - <system_message level="4" line="1" source="test data" type="SEVERE"> - <paragraph> - Title overline & underline mismatch. - <literal_block xml:space="preserve"> - ======= - Title - ------- - <paragraph> - Paragraph. -"""], -["""\ -======================== - -======================== - -Test missing titles; blank line in-between. - -======================== - -======================== -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Document or section may not begin with a transition. - <transition> - <system_message level="3" line="3" source="test data" type="ERROR"> - <paragraph> - At least one body element must separate transitions; adjacent transitions not allowed. - <transition> - <paragraph> - Test missing titles; blank line in-between. - <transition> - <transition> - <system_message level="3" line="9" source="test data" type="ERROR"> - <paragraph> - Document or section may not end with a transition. -"""], -["""\ -======================== -======================== - -Test missing titles; nothing in-between. - -======================== -======================== -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Invalid section title or transition marker. - <literal_block xml:space="preserve"> - ======================== - ======================== - <paragraph> - Test missing titles; nothing in-between. - <system_message level="3" line="6" source="test data" type="ERROR"> - <paragraph> - Invalid section title or transition marker. - <literal_block xml:space="preserve"> - ======================== - ======================== -"""], -["""\ -.. 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 source="test data"> - <comment xml:space="preserve"> - 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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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" line="15" source="test data" type="SEVERE"> - <paragraph> - Title level inconsistent: - <literal_block xml:space="preserve"> - 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 source="test data"> - <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" line="19" source="test data" type="SEVERE"> - <paragraph> - Title level inconsistent: - <literal_block xml:space="preserve"> - ``````` - Title 4 - ``````` - <paragraph> - Paragraph 4. -"""], -["""\ -Title containing *inline* ``markup`` -==================================== - -Paragraph. -""", -"""\ -<document source="test data"> - <section id="title-containing-inline-markup" name="title containing inline markup"> - <title> - Title containing \n\ - <emphasis> - inline - \n\ - <literal> - markup - <paragraph> - Paragraph. -"""], -["""\ -1. Numbered Title -================= - -Paragraph. -""", -"""\ -<document source="test data"> - <section id="numbered-title" name="1. numbered title"> - <title> - 1. Numbered Title - <paragraph> - Paragraph. -"""], -["""\ -1. Item 1. -2. Item 2. -3. Numbered Title -================= - -Paragraph. -""", -"""\ -<document source="test data"> - <enumerated_list enumtype="arabic" prefix="" suffix="."> - <list_item> - <paragraph> - Item 1. - <list_item> - <paragraph> - Item 2. - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Enumerated list ends without a blank line; unexpected unindent. - <section id="numbered-title" name="3. numbered title"> - <title> - 3. Numbered Title - <paragraph> - Paragraph. -"""], -["""\ -ABC -=== - -Short title. -""", -"""\ -<document source="test data"> - <section id="abc" name="abc"> - <title> - ABC - <paragraph> - Short title. -"""], -["""\ -ABC -== - -Underline too short. -""", -"""\ -<document source="test data"> - <system_message level="1" line="2" source="test data" type="INFO"> - <paragraph> - Possible title underline, too short for the title. - Treating it as ordinary text because it's so short. - <paragraph> - ABC - == - <paragraph> - Underline too short. -"""], -["""\ -== -ABC -== - -Over & underline too short. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <paragraph> - == - ABC - == - <paragraph> - Over & underline too short. -"""], -["""\ -== -ABC - -Overline too short, no underline. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <paragraph> - == - ABC - <paragraph> - Overline too short, no underline. -"""], -["""\ -== -ABC -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <paragraph> - == - ABC -"""], -["""\ -== - Not a title: a definition list item. -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <definition_list> - <definition_list_item> - <term> - == - <definition> - <paragraph> - Not a title: a definition list item. -"""], -["""\ -== - Not a title: a definition list item. --- - Another definition list item. It's in a different list, - but that's an acceptable limitation given that this will - probably never happen in real life. - - The next line will trigger a warning: -== -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <definition_list> - <definition_list_item> - <term> - == - <definition> - <paragraph> - Not a title: a definition list item. - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Definition list ends without a blank line; unexpected unindent. - <system_message level="1" line="3" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <definition_list> - <definition_list_item> - <term> - -- - <definition> - <paragraph> - Another definition list item. It's in a different list, - but that's an acceptable limitation given that this will - probably never happen in real life. - <paragraph> - The next line will trigger a warning: - <system_message level="2" line="9" source="test data" type="WARNING"> - <paragraph> - Definition list ends without a blank line; unexpected unindent. - <paragraph> - == -"""], -["""\ -Paragraph - - == - ABC - == - - Over & underline too short. -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph - <block_quote> - <system_message level="1" line="3" source="test data" type="INFO"> - <paragraph> - Unexpected possible title overline or transition. - Treating it as ordinary text because it's so short. - <paragraph> - == - ABC - == - <paragraph> - Over & underline too short. -"""], -["""\ -Paragraph - - ABC - == - - Underline too short. -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph - <block_quote> - <paragraph> - ABC - == - <paragraph> - Underline too short. -"""], -["""\ -... -... - -... ---- - -... -... -... -""", -"""\ -<document source="test data"> - <system_message level="1" line="1" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <section dupname="..." id="id1"> - <title> - ... - <system_message level="1" line="4" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <section dupname="..." id="id2"> - <title> - ... - <system_message backrefs="id2" level="1" line="5" source="test data" type="INFO"> - <paragraph> - Duplicate implicit target name: "...". - <system_message level="1" line="7" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <system_message level="1" line="7" source="test data" type="INFO"> - <paragraph> - Possible incomplete section title. - Treating the overline as ordinary text because it's so short. - <section dupname="..." id="id3"> - <title> - ... - <system_message backrefs="id3" level="1" line="8" source="test data" type="INFO"> - <paragraph> - Duplicate implicit target name: "...". - <paragraph> - ... -"""], -["""\ -.. -Hi -.. - -... -Yo -... - -Ho -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <section id="hi" name="hi"> - <title> - Hi - <section id="yo" name="yo"> - <title> - Yo - <paragraph> - Ho -"""], -["""\ -Empty Section -============= -""", -"""\ -<document source="test data"> - <section id="empty-section" name="empty section"> - <title> - Empty Section - <system_message level="3" line="2" source="test data" type="ERROR"> - <paragraph> - Section empty; must have contents. -"""], -["""\ -=== -One -=== - -The bubble-up parser strategy conflicts with short titles -(<= 3 char-long over- & underlines). - -=== -Two -=== - -The parser currently contains a work-around kludge. -Without it, the parser ends up in an infinite loop. -""", -"""\ -<document source="test data"> - <section id="one" name="one"> - <title> - One - <paragraph> - The bubble-up parser strategy conflicts with short titles - (<= 3 char-long over- & underlines). - <section id="two" name="two"> - <title> - Two - <paragraph> - The parser currently contains a work-around kludge. - Without it, the parser ends up in an infinite loop. -"""], -["""\ -""", -"""\ -<document source="test data"> - <system_message level="3" line="0" source="test data" type="ERROR"> - <paragraph> - Document empty; must have contents. -"""], -] - - -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 ecbe5eab1..000000000 --- a/docutils/test/test_parsers/test_rst/test_substitutions.py +++ /dev/null @@ -1,231 +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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 block quote. -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "image" directive: - no content permitted. - <literal_block xml:space="preserve"> - image:: symbol.png - \n\ - Followed by a block quote. - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Substitution definition "symbol 1" empty or invalid. - <literal_block xml:space="preserve"> - .. |symbol 1| image:: symbol.png - \n\ - Followed by a block quote. -"""], -["""\ -.. |symbol 1| image:: symbol.png - -Followed by a paragraph. - -.. |symbol 2| image:: symbol.png - -.. - - Followed by a block quote. -""", -"""\ -<document source="test data"> - <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"> - <comment xml:space="preserve"> - <block_quote> - <paragraph> - Followed by a block quote. -"""], -[u"""\ -Substitutions support case differences: - -.. |eacute| replace:: \u00E9 -.. |Eacute| replace:: \u00C9 -""", -u"""\ -<document source="test data"> - <paragraph> - Substitutions support case differences: - <substitution_definition name="eacute"> - \u00E9 - <substitution_definition name="Eacute"> - \u00C9 -"""], -["""\ -Here are some duplicate substitution definitions: - -.. |symbol| image:: symbol.png -.. |symbol| image:: symbol.png -""", -"""\ -<document source="test data"> - <paragraph> - Here are some duplicate substitution definitions: - <substitution_definition dupname="symbol"> - <image alt="symbol" uri="symbol.png"> - <system_message level="3" line="4" source="test data" 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 source="test data"> - <paragraph> - Here are some bad cases: - <substitution_definition name="symbol"> - <image alt="symbol" uri="symbol.png"> - <system_message level="2" line="4" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <paragraph> - No blank line after. - <system_message level="2" line="6" source="test data" type="WARNING"> - <paragraph> - Substitution definition "empty" missing contents. - <literal_block xml:space="preserve"> - .. |empty| - <system_message level="1" line="8" source="test data" type="INFO"> - <paragraph> - No directive entry for "directive" in module "docutils.parsers.rst.languages.en". - Trying "directive" as canonical directive name. - <system_message level="3" line="8" source="test data" type="ERROR"> - <paragraph> - Unknown directive type "directive". - <literal_block xml:space="preserve"> - directive:: symbol.png - <system_message level="2" line="8" source="test data" type="WARNING"> - <paragraph> - Substitution definition "unknown" empty or invalid. - <literal_block xml:space="preserve"> - .. |unknown| directive:: symbol.png - <system_message level="2" line="10" source="test data" type="WARNING"> - <paragraph> - Substitution definition "invalid 1" empty or invalid. - <literal_block xml:space="preserve"> - .. |invalid 1| there's no directive here - <system_message level="2" line="11" source="test data" type="WARNING"> - <paragraph> - Substitution definition "invalid 2" empty or invalid. - <literal_block xml:space="preserve"> - .. |invalid 2| there's no directive here - With some block quote text, line 1. - And some more, line 2. - <system_message level="2" line="15" source="test data" type="WARNING"> - <paragraph> - Substitution definition "invalid 3" empty or invalid. - <literal_block xml:space="preserve"> - .. |invalid 3| there's no directive here - <comment xml:space="preserve"> - | 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 d0d1d1317..000000000 --- a/docutils/test/test_parsers/test_rst/test_tables.py +++ /dev/null @@ -1,1151 +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['full_tables'] = [ -["""\ -+-------------------------------------+ -| A table with one cell and one line. | -+-------------------------------------+ -""", -"""\ -<document source="test data"> - <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 source="test data"> - <table> - <tgroup cols="1"> - <colspec colwidth="23"> - <tbody> - <row> - <entry> - <paragraph> - A table with one cell - and two lines. -"""], -["""\ -+-----------------------+ -| A malformed table. | -+-----------------------+ -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Malformed table. - <literal_block xml:space="preserve"> - +-----------------------+ - | A malformed table. | - +-----------------------+ -"""], -["""\ -+------------------------+ -| A well-formed | table. | -+------------------------+ - -+------------------------+ -| This +----------+ too! | -+------------------------+ -""", -"""\ -<document source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <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" line="6" source="test data" type="WARNING"> - <paragraph> - Blank line required after table. - <paragraph> - No blank line after table. -"""], -["""\ -+-----------------+--------+ -| A simple table | cell 2 | -+-----------------+--------+ -| cell 3 | cell 4 | -+-----------------+--------+ - Unexpected indent and no blank line after table. -""", -"""\ -<document source="test data"> - <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" line="6" source="test data" type="ERROR"> - <paragraph> - Unexpected indentation. - <system_message level="2" line="6" source="test data" type="WARNING"> - <paragraph> - Blank line required after table. - <block_quote> - <paragraph> - Unexpected indent and no blank line after table. -"""], -["""\ -+--------------+-------------+ -| A bad table. | | -+--------------+ | -| Cells must be rectangles. | -+----------------------------+ -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Malformed table. - Malformed table; parse incomplete. - <literal_block xml:space="preserve"> - +--------------+-------------+ - | A bad table. | | - +--------------+ | - | Cells must be rectangles. | - +----------------------------+ -"""], -["""\ -+------------------------------+ -| This table contains another. | -| | -| +-------------------------+ | -| | A table within a table. | | -| +-------------------------+ | -+------------------------------+ -""", -"""\ -<document source="test data"> - <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 source="test data"> - <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> -"""], -] - -totest['simple_tables'] = [ -["""\ -============ ============ -A table with two columns. -============ ============ - -Paragraph. -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="2"> - <colspec colwidth="12"> - <colspec colwidth="12"> - <tbody> - <row> - <entry> - <paragraph> - A table with - <entry> - <paragraph> - two columns. - <paragraph> - Paragraph. -"""], -["""\ -============ ============ -A table with two columns -and two rows. -============ ============ -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="2"> - <colspec colwidth="12"> - <colspec colwidth="12"> - <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 source="test data"> - <table> - <tgroup cols="2"> - <colspec colwidth="12"> - <colspec colwidth="14"> - <tbody> - <row> - <entry> - <paragraph> - A table with - <entry> - <paragraph> - two columns, - <row> - <entry morecols="1"> - <paragraph> - two rows, and a column span. -"""], -["""\ -== =========== =========== -1 A table with three rows, --- ------------------------ -2 and three columns. -3 First and third rows - contain column spans. - - This row is a multi-line row, and overflows to the right. --- ------------------------ -4 One last row. -== =========== =========== -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="3"> - <colspec colwidth="2"> - <colspec colwidth="11"> - <colspec colwidth="44"> - <tbody> - <row> - <entry> - <paragraph> - 1 - <entry morecols="1"> - <paragraph> - A table with three rows, - <row> - <entry> - <paragraph> - 2 - <entry> - <paragraph> - and three - <entry> - <paragraph> - columns. - <row> - <entry> - <paragraph> - 3 - <entry morecols="1"> - <paragraph> - First and third rows - contain column spans. - <paragraph> - This row is a multi-line row, and overflows to the right. - <row> - <entry> - <paragraph> - 4 - <entry> - <paragraph> - One last - <entry> - <paragraph> - row. -"""], -["""\ -======= ========= ======== -A table with three columns. -================== ======== -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="3"> - <colspec colwidth="7"> - <colspec colwidth="9"> - <colspec colwidth="8"> - <tbody> - <row> - <entry morecols="1"> - <paragraph> - A table with three - <entry> - <paragraph> - columns. -"""], -["""\ -============== ====== -A simple table with -no bottom border -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Malformed table. - No bottom table border found. - <literal_block xml:space="preserve"> - ============== ====== - A simple table with - no bottom border -"""], -["""\ -============== ====== -A simple table cell 2 -cell 3 cell 4 -============== ====== -No blank line after table. -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Malformed table. - No bottom table border found or no blank line after table bottom. - <literal_block xml:space="preserve"> - ============== ====== - A simple table cell 2 - cell 3 cell 4 - ============== ====== - <system_message level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Blank line required after table. - <paragraph> - No blank line after table. -"""], -["""\ -============== ====== -A simple table cell 2 -============== ====== -cell 3 cell 4 -============== ====== -No blank line after table. -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="2"> - <colspec colwidth="14"> - <colspec colwidth="6"> - <thead> - <row> - <entry> - <paragraph> - A simple table - <entry> - <paragraph> - cell 2 - <tbody> - <row> - <entry> - <paragraph> - cell 3 - <entry> - <paragraph> - cell 4 - <system_message level="2" line="6" source="test data" type="WARNING"> - <paragraph> - Blank line required after table. - <paragraph> - No blank line after table. -"""], -["""\ -============== ====== -A simple table cell 2 -cell 3 cell 4 -============== ====== - Unexpected indent and no blank line after table. -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Malformed table. - No bottom table border found or no blank line after table bottom. - <literal_block xml:space="preserve"> - ============== ====== - A simple table cell 2 - cell 3 cell 4 - ============== ====== - <system_message level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Blank line required after table. - <block_quote> - <paragraph> - Unexpected indent and no blank line after table. -"""], -["""\ -============== ====== -A bad table cell 2 -cell 3 cell 4 -============ ======== -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Malformed table. - Column span alignment problem at line offset 2. - <literal_block xml:space="preserve"> - ============== ====== - A bad table cell 2 - cell 3 cell 4 - ============ ======== -"""], -["""\ -======== ========= -A bad table cell 2 -cell 3 cell 4 -======== ========= -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Malformed table. - Text in column margin at line offset 1. - <literal_block xml:space="preserve"> - ======== ========= - A bad table cell 2 - cell 3 cell 4 - ======== ========= -"""], -["""\ -== ============================ -1 This table contains another. -2 ======= ====== ======== - A table within a table. - ======= ====== ======== - - The outer table does have to - have at least two columns - though. -== ============================ -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="2"> - <colspec colwidth="2"> - <colspec colwidth="28"> - <tbody> - <row> - <entry> - <paragraph> - 1 - <entry> - <paragraph> - This table contains another. - <row> - <entry> - <paragraph> - 2 - <entry> - <table> - <tgroup cols="3"> - <colspec colwidth="7"> - <colspec colwidth="6"> - <colspec colwidth="8"> - <tbody> - <row> - <entry> - <paragraph> - A table - <entry> - <paragraph> - within - <entry> - <paragraph> - a table. - <paragraph> - The outer table does have to - have at least two columns - though. -"""], -["""\ -================ ====== -A simple table -with empty cells -================ ====== -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="2"> - <colspec colwidth="16"> - <colspec colwidth="6"> - <tbody> - <row> - <entry> - <paragraph> - A simple table - <entry> - <row> - <entry> - <paragraph> - with empty cells - <entry> -"""], -["""\ -============== ======== - A table with -============== ======== - centered cells. - -============== ======== -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="2"> - <colspec colwidth="14"> - <colspec colwidth="8"> - <thead> - <row> - <entry> - <paragraph> - A table - <entry> - <paragraph> - with - <tbody> - <row> - <entry> - <paragraph> - centered - <entry> - <paragraph> - cells. -"""], -["""\ -============== ====== -A simple table this text extends to the right -cell 3 the bottom border below is too long -============== ======== -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Malformed table. - Bottom/header table border does not match top border. - <literal_block xml:space="preserve"> - ============== ====== - A simple table this text extends to the right - cell 3 the bottom border below is too long - ============== ======== -"""], -["""\ -============ ================= -A table with row separators. ------------- ----------------- - -Blank line before. ------------- ----------------- - -Blank lines before and after. - ------------- ----------------- -Blank line after. - -============ ================= -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="2"> - <colspec colwidth="12"> - <colspec colwidth="17"> - <tbody> - <row> - <entry> - <paragraph> - A table with - <entry> - <paragraph> - row separators. - <row> - <entry> - <paragraph> - Blank line - <entry> - <paragraph> - before. - <row> - <entry> - <paragraph> - Blank lines - <entry> - <paragraph> - before and after. - <row> - <entry> - <paragraph> - Blank line - <entry> - <paragraph> - after. -"""], -["""\ -============ ==================== -A table with many row separators. ------------- -------------------- ------------- -------------------- - ------------- -------------------- -============ ==================== -""", -"""\ -<document source="test data"> - <table> - <tgroup cols="2"> - <colspec colwidth="12"> - <colspec colwidth="20"> - <tbody> - <row> - <entry> - <paragraph> - A table with - <entry> - <paragraph> - many row separators. - <row> - <entry> - <entry> - <row> - <entry> - <entry> - <row> - <entry> - <entry> -"""], -["""\ -== =========== =========== -1 Span columns 2 & 3 --- ------------------------ -2 Span columns 2 & 3 - ------------------------ -3 -== =========== =========== - -== =========== =========== -1 Span cols 1&2 but not 3 ---------------- ----------- -2 Span cols 1&2 but not 3 ---------------- -3 no spans here -== =========== =========== - -== =========== =========== -1 Not a span Not a span - ----------- ----------- -2 -== =========== =========== -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Malformed table. - Text in column margin at line offset 3. - <literal_block xml:space="preserve"> - == =========== =========== - 1 Span columns 2 & 3 - -- ------------------------ - 2 Span columns 2 & 3 - ------------------------ - 3 - == =========== =========== - <system_message level="3" line="9" source="test data" type="ERROR"> - <paragraph> - Malformed table. - Column span incomplete at line offset 4. - <literal_block xml:space="preserve"> - == =========== =========== - 1 Span cols 1&2 but not 3 - --------------- ----------- - 2 Span cols 1&2 but not 3 - --------------- - 3 no spans here - == =========== =========== - <table> - <tgroup cols="3"> - <colspec colwidth="2"> - <colspec colwidth="11"> - <colspec colwidth="11"> - <tbody> - <row> - <entry> - <paragraph> - 1 - <entry> - <system_message level="4" line="20" source="test data" type="SEVERE"> - <paragraph> - Unexpected section title. - <literal_block xml:space="preserve"> - Not a span - ----------- - <entry> - <system_message level="4" line="20" source="test data" type="SEVERE"> - <paragraph> - Unexpected section title. - <literal_block xml:space="preserve"> - Not a span - ----------- - <row> - <entry> - <paragraph> - 2 - <entry> - <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 f246ccf6e..000000000 --- a/docutils/test/test_parsers/test_rst/test_targets.py +++ /dev/null @@ -1,448 +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 source="test data"> - <target id="target" name="target"> - <paragraph> - (Internal hyperlink target.) -"""], -["""\ -.. _optional space before colon : -""", -"""\ -<document source="test data"> - <target id="optional-space-before-colon" name="optional space before colon"> -"""], -["""\ -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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Hyperlink target contains whitespace. Perhaps a footnote was intended? - <literal_block xml:space="preserve"> - .. _target1: Not a proper hyperlink target - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Hyperlink target contains whitespace. Perhaps a footnote was intended? - <literal_block xml:space="preserve"> - .. _target2: Although it ends with an underscore, this is not a phrase-link_ - <system_message level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Hyperlink target contains whitespace. Perhaps a footnote was intended? - <literal_block xml:space="preserve"> - .. _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 source="test data"> - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Hyperlink target contains whitespace. Perhaps a footnote was intended? - <literal_block xml:space="preserve"> - .. __: Not a proper hyperlink target - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Anonymous hyperlink target contains whitespace. Perhaps a footnote was intended? - <literal_block xml:space="preserve"> - __ Although it ends with an underscore, this is not a phrase-link_ - <system_message level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Anonymous hyperlink target contains whitespace. Perhaps a footnote was intended? - <literal_block xml:space="preserve"> - __ 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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <paragraph> - External hyperlink: - <target id="target" name="target" refuri="http://www.python.org/"> -"""], -["""\ -.. _email: jdoe@example.com - -.. _multi-line email: jdoe - @example.com -""", -"""\ -<document source="test data"> - <target id="email" name="email" refuri="mailto:jdoe@example.com"> - <target id="multi-line-email" name="multi-line email" refuri="mailto:jdoe@example.com"> -"""], -["""\ -Duplicate external targets (different URIs): - -.. _target: first - -.. _target: second -""", -"""\ -<document source="test data"> - <paragraph> - Duplicate external targets (different URIs): - <target dupname="target" id="target" refuri="first"> - <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "target". - <target dupname="target" id="id1" refuri="second"> -"""], -["""\ -Duplicate external targets (same URIs): - -.. _target: first - -.. _target: first -""", -"""\ -<document source="test data"> - <paragraph> - Duplicate external targets (same URIs): - <target id="target" name="target" refuri="first"> - <system_message backrefs="id1" level="1" line="5" source="test data" type="INFO"> - <paragraph> - Duplicate explicit target name: "target". - <target dupname="target" id="id1" refuri="first"> -"""], -["""\ -Duplicate implicit targets. - -Title -===== - -Paragraph. - -Title -===== - -Paragraph. -""", -"""\ -<document source="test data"> - <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" line="9" source="test data" type="INFO"> - <paragraph> - Duplicate implicit target name: "title". - <paragraph> - Paragraph. -"""], -["""\ -Duplicate implicit/explicit targets. - -Title -===== - -.. _title: - -Paragraph. -""", -"""\ -<document source="test data"> - <paragraph> - Duplicate implicit/explicit targets. - <section dupname="title" id="title"> - <title> - Title - <system_message backrefs="id1" level="1" line="6" source="test data" 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 source="test data"> - <paragraph> - Duplicate explicit targets. - <target dupname="title" id="title"> - <paragraph> - First. - <system_message backrefs="id1" level="2" line="7" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "title". - <target dupname="title" id="id1"> - <paragraph> - Second. - <system_message backrefs="id2" level="2" line="11" source="test data" 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 source="test data"> - <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" line="8" source="test data" type="INFO"> - <paragraph> - Duplicate implicit target name: "target". - <paragraph> - Citation target. - <footnote auto="1" dupname="target" id="id2"> - <system_message backrefs="id2" level="2" line="10" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "target". - <paragraph> - Autonumber-labeled footnote target. - <system_message backrefs="id3" level="2" line="12" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "target". - <target dupname="target" id="id3"> - <paragraph> - Explicit internal target. - <system_message backrefs="id4" level="2" line="16" source="test data" 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 source="test data"> - <paragraph> - Anonymous external hyperlink target: - <target anonymous="1" id="id1" refuri="http://w3c.org/"> -"""], -["""\ -Anonymous external hyperlink target: - -__ http://w3c.org/ -""", -"""\ -<document source="test data"> - <paragraph> - Anonymous external hyperlink target: - <target anonymous="1" id="id1" refuri="http://w3c.org/"> -"""], -["""\ -Anonymous indirect hyperlink target: - -.. __: reference_ -""", -"""\ -<document source="test data"> - <paragraph> - Anonymous indirect hyperlink target: - <target anonymous="1" id="id1" refname="reference"> -"""], -["""\ -Anonymous indirect hyperlink targets: - -__ reference_ -__ `a very long - reference`_ -""", -"""\ -<document source="test data"> - <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 source="test data"> - <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" line="7" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <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" line="13" source="test data" type="WARNING"> - <paragraph> - Explicit markup ends without a blank line; unexpected unindent. - <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 3e8a63e91..000000000 --- a/docutils/test/test_parsers/test_rst/test_transitions.py +++ /dev/null @@ -1,220 +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 source="test data"> - <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 source="test data"> - <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 source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Document or section may not begin with a transition. - <transition> - <paragraph> - A section or document may not begin with a transition. - <paragraph> - The DTD specifies that two transitions may not - be adjacent: - <transition> - <system_message level="3" line="10" source="test data" type="ERROR"> - <paragraph> - At least one body element must separate transitions; adjacent transitions not allowed. - <transition> - <system_message level="3" line="12" source="test data" type="ERROR"> - <paragraph> - At least one body element must separate transitions; adjacent transitions not allowed. - <transition> - <paragraph> - The DTD also specifies that a section or document - may not end with a transition. - <transition> - <system_message level="3" line="17" source="test data" type="ERROR"> - <paragraph> - Document or section may not end with a transition. -"""], -["""\ -Test unexpected transition markers. - - Block quote. - - -------- - - Paragraph. -""", -"""\ -<document source="test data"> - <paragraph> - Test unexpected transition markers. - <block_quote> - <paragraph> - Block quote. - <system_message level="4" line="5" source="test data" type="SEVERE"> - <paragraph> - Unexpected section title or transition. - <literal_block xml:space="preserve"> - -------- - <paragraph> - Paragraph. -"""], -["""\ -Short transition marker. - ---- - -Paragraph -""", -"""\ -<document source="test data"> - <paragraph> - Short transition marker. - <paragraph> - --- - <paragraph> - Paragraph -"""], -["""\ -Sections with transitions at beginning and end. - -Section 1 -========= - ----------- - -Illegal transitions. - ----------- - -Section 2 -========= - ----------- -""", -"""\ -<document source="test data"> - <paragraph> - Sections with transitions at beginning and end. - <section id="section-1" name="section 1"> - <title> - Section 1 - <system_message level="3" line="6" source="test data" type="ERROR"> - <paragraph> - Section may not begin with a transition. - <transition> - <paragraph> - Illegal transitions. - <transition> - <system_message level="3" line="10" source="test data" type="ERROR"> - <paragraph> - Section may not end with a transition. - <section id="section-2" name="section 2"> - <title> - Section 2 - <system_message level="3" line="15" source="test data" type="ERROR"> - <paragraph> - Section may not begin with a transition. - <transition> - <system_message level="3" line="15" source="test data" type="ERROR"> - <paragraph> - Document or section may not end with a transition. -"""], -["""\ ----------- - -Document beginning with a transition. -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Document or section may not begin with a transition. - <transition> - <paragraph> - Document beginning with a transition. -"""], -] - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_readers/__init__.py b/docutils/test/test_readers/__init__.py deleted file mode 100644 index 2fe79c55c..000000000 --- a/docutils/test/test_readers/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import os.path -import sys - -sys.path.insert(0, os.path.abspath(os.curdir)) -prev = '' -while sys.path[0] != prev: - try: - import DocutilsTestSupport - break - except ImportError: - prev = sys.path[0] - sys.path[0] = os.path.dirname(prev) -sys.path.pop(0) diff --git a/docutils/test/test_readers/test_pep/__init__.py b/docutils/test/test_readers/test_pep/__init__.py deleted file mode 100644 index 2fe79c55c..000000000 --- a/docutils/test/test_readers/test_pep/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import os.path -import sys - -sys.path.insert(0, os.path.abspath(os.curdir)) -prev = '' -while sys.path[0] != prev: - try: - import DocutilsTestSupport - break - except ImportError: - prev = sys.path[0] - sys.path[0] = os.path.dirname(prev) -sys.path.pop(0) diff --git a/docutils/test/test_readers/test_pep/test_inline_markup.py b/docutils/test/test_readers/test_pep/test_inline_markup.py deleted file mode 100644 index 7ae69e8ec..000000000 --- a/docutils/test/test_readers/test_pep/test_inline_markup.py +++ /dev/null @@ -1,140 +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 inline markup in PEPs (readers/pep.py). -""" - -from __init__ import DocutilsTestSupport - - -def suite(): - s = DocutilsTestSupport.PEPParserTestSuite() - s.generateTests(totest) - return s - - -totest = {} - -totest['standalone_references'] = [ -["""\ -See PEP 287 (pep-0287.txt), -and RFC 2822 (which obsoletes RFC822 and RFC-733). -""", -"""\ -<document source="test data"> - <paragraph> - See \n\ - <reference refuri="pep-0287.html"> - PEP 287 - ( - <reference refuri="pep-0287.html"> - pep-0287.txt - ), - and \n\ - <reference refuri="http://www.faqs.org/rfcs/rfc2822.html"> - RFC 2822 - (which obsoletes \n\ - <reference refuri="http://www.faqs.org/rfcs/rfc822.html"> - RFC822 - and \n\ - <reference refuri="http://www.faqs.org/rfcs/rfc733.html"> - RFC-733 - ). -"""], -["""\ -References split across lines: - -PEP -287 - -RFC -2822 -""", -"""\ -<document source="test data"> - <paragraph> - References split across lines: - <paragraph> - <reference refuri="pep-0287.html"> - PEP - 287 - <paragraph> - <reference refuri="http://www.faqs.org/rfcs/rfc2822.html"> - RFC - 2822 -"""], -["""\ -Test PEP-specific implicit references before a URL: - -PEP 287 (http://www.python.org/peps/pep-0287.html), RFC 2822. -""", -"""\ -<document source="test data"> - <paragraph> - Test PEP-specific implicit references before a URL: - <paragraph> - <reference refuri="pep-0287.html"> - PEP 287 - ( - <reference refuri="http://www.python.org/peps/pep-0287.html"> - http://www.python.org/peps/pep-0287.html - ), \n\ - <reference refuri="http://www.faqs.org/rfcs/rfc2822.html"> - RFC 2822 - . -"""], -] - -totest['miscellaneous'] = [ -["""\ -For *completeness*, _`let's` ``test`` **other** forms_ -|of| `inline markup` [*]_. - -.. [*] See http://docutils.sf.net/spec/rst/reStructuredText.html. -""", -"""\ -<document source="test data"> - <paragraph> - For \n\ - <emphasis> - completeness - , \n\ - <target id="let-s" name="let's"> - let's - \n\ - <literal> - test - \n\ - <strong> - other - \n\ - <reference refname="forms"> - forms - \n\ - <substitution_reference refname="of"> - of - \n\ - <title_reference> - inline markup - \n\ - <footnote_reference auto="*" id="id1"> - . - <footnote auto="*" id="id2"> - <paragraph> - See \n\ - <reference refuri="http://docutils.sf.net/spec/rst/reStructuredText.html"> - http://docutils.sf.net/spec/rst/reStructuredText.html - . -"""], -] - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_readers/test_pep/test_rfc2822.py b/docutils/test/test_readers/test_pep/test_rfc2822.py deleted file mode 100644 index f13de16d2..000000000 --- a/docutils/test/test_readers/test_pep/test_rfc2822.py +++ /dev/null @@ -1,291 +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 RFC-2822 headers in PEPs (readers/pep.py). -""" - -from __init__ import DocutilsTestSupport - -def suite(): - s = DocutilsTestSupport.PEPParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['rfc2822'] = [ -["""\ -Author: Me -Version: 1 -Date: 2002-04-23 -""", -"""\ -<document source="test data"> - <field_list class="rfc2822"> - <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 source="test data"> - <field_list class="rfc2822"> - <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 - <comment xml:space="preserve"> - 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 source="test data"> - <comment xml:space="preserve"> - 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 source="test data"> - <field_list class="rfc2822"> - <field> - <field_name> - Author - <field_body> - <paragraph> - Me - <paragraph> - Version: 1 - Date: 2002-04-23 -"""], -["""\ -field: -empty item above, no blank line -""", -"""\ -<document source="test data"> - <field_list class="rfc2822"> - <field> - <field_name> - field - <field_body> - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - RFC2822-style field list ends without a blank line; unexpected unindent. - <paragraph> - empty item above, no blank line -"""], -["""\ -Author: - Me -Version: - 1 -Date: - 2002-04-23 -""", -"""\ -<document source="test data"> - <field_list class="rfc2822"> - <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 source="test data"> - <field_list class="rfc2822"> - <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 source="test data"> - <field_list class="rfc2822"> - <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 -Version: -""", -"""\ -<document source="test data"> - <field_list class="rfc2822"> - <field> - <field_name> - Authors - <field_body> - <bullet_list bullet="-"> - <list_item> - <paragraph> - Me - <list_item> - <paragraph> - Myself - <list_item> - <paragraph> - I - <field> - <field_name> - Version - <field_body> -"""], -["""\ -Authors: Me - - Myself and I -Version: -""", -"""\ -<document source="test data"> - <field_list class="rfc2822"> - <field> - <field_name> - Authors - <field_body> - <paragraph> - Me - <block_quote> - <paragraph> - Myself and I - <system_message level="2" line="4" source="test data" type="WARNING"> - <paragraph> - Block quote ends without a blank line; unexpected unindent. - <paragraph> - Version: -"""], -] - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_readers/test_python/__init__.py b/docutils/test/test_readers/test_python/__init__.py deleted file mode 100644 index 2fe79c55c..000000000 --- a/docutils/test/test_readers/test_python/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import os.path -import sys - -sys.path.insert(0, os.path.abspath(os.curdir)) -prev = '' -while sys.path[0] != prev: - try: - import DocutilsTestSupport - break - except ImportError: - prev = sys.path[0] - sys.path[0] = os.path.dirname(prev) -sys.path.pop(0) diff --git a/docutils/test/test_readers/test_python/showast b/docutils/test/test_readers/test_python/showast deleted file mode 100755 index e7d846307..000000000 --- a/docutils/test/test_readers/test_python/showast +++ /dev/null @@ -1,57 +0,0 @@ -#! /usr/bin/env python - -""" -This is a tool for exploring abstract syntax trees generated by -``compiler.parse()`` from test data in -docutils/test/test_readers/test_python/test_parser or stdin. - -Usage:: - - showast <key> <index> - - showast < <module.py> - -Where ``<key>`` is the key to the ``totest`` dictionary, and ``<index>`` is -the index of the list ``totest[key]``. If no arguments are given, stdin is -used for input. -""" - -import sys -import compiler -from compiler.ast import Node -import test_parser - -def pformat(ast, indent=' ', level=0): - assert isinstance(ast, Node), 'ast is not a Node: %r' % (ast,) - atts = {} - for name, value in vars(ast).items(): - if not value or isinstance(value, Node): - continue - if isinstance(value, list): - if isinstance(value[0], Node): - continue - if isinstance(value[0], tuple) and value[0] \ - and isinstance(value[0][0], Node): - continue - atts[name] = str(value).encode('unicode-escape') - attlist = atts.items() - attlist.sort() - parts = [ast.__class__.__name__] - for name, value in attlist: - parts.append('%s="%s"' % (name, value)) - result = ['%s<%s>\n' % (indent * level, ' '.join(parts))] - for node in ast.getChildNodes(): - result.extend(pformat(node, level=level+1)) - return result - -if len(sys.argv) > 1: - key, caseno = sys.argv[1:] - print 'totest["%s"][%s][0]:\n' % (key, caseno) - input_text = test_parser.totest[key][int(caseno)][0] -else: - input_text = sys.stdin.read() -print input_text -module = compiler.parse(input_text) -print module -print -print ''.join(pformat(module)), diff --git a/docutils/test/test_readers/test_python/showdoc b/docutils/test/test_readers/test_python/showdoc deleted file mode 100755 index 6461960f8..000000000 --- a/docutils/test/test_readers/test_python/showdoc +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env python - -""" -This is a tool for exploring module documentation trees generated by -``docutils.readers.python.moduleparser.parse_module()`` from test data in -docutils/test/test_readers/test_python/test_parser or stdin. - -Usage:: - - showdoc <key> <index> - - showdoc < <module.py> - -Where ``<key>`` is the key to the ``totest`` dictionary, and ``<index>`` is -the index of the list ``totest[key]``. If no arguments are given, stdin is -used for input. -""" - -import sys -from docutils.readers.python.moduleparser import parse_module -import test_parser - -if len(sys.argv) > 1: - key, caseno = sys.argv[1:] - print 'totest["%s"][%s][0]:\n' % (key, caseno) - input_text = test_parser.totest[key][int(caseno)][0] - input_source = "test_parser.totest['%s'][%s][0]" % (key, caseno) -else: - input_text = sys.stdin.read() - input_source = '<stdin>' -print input_text -module = parse_module(input_text, input_source) -print module, diff --git a/docutils/test/test_readers/test_python/showparse b/docutils/test/test_readers/test_python/showparse deleted file mode 100755 index 8144256d6..000000000 --- a/docutils/test/test_readers/test_python/showparse +++ /dev/null @@ -1,48 +0,0 @@ -#! /usr/bin/env python - -""" -This is a tool for exploring abstract syntax trees generated by -``parser.suite()`` from test data in -docutils/test/test_readers/test_python/test_parser or stdin. - -Usage:: - - showparse <key> <index> - - showparse < <module.py> - -Where ``<key>`` is the key to the ``totest`` dictionary, and ``<index>`` is -the index of the list ``totest[key]``. If no arguments are given, stdin is -used for input. -""" - -import sys -import types -import parser -import token -import symbol -import pprint -import test_parser - -names = token.tok_name.copy() -names.update(symbol.sym_name) - -def name_elements(ast): - if ast: - name = names[ast[0]] - ast[0] = '%s (%s)' % (name, ast[0]) - for node in ast[1:]: - if type(node) == types.ListType: - name_elements(node) - -if len(sys.argv) > 1: - key, caseno = sys.argv[1:] - print 'totest["%s"][%s][0]:\n' % (key, caseno) - input_text = test_parser.totest[key][int(caseno)][0] -else: - input_text = sys.stdin.read() -print input_text -module = parser.suite(input_text) -ast = parser.ast2list(module, line_info=1) -name_elements(ast) -pprint.pprint(ast) diff --git a/docutils/test/test_readers/test_python/showtok b/docutils/test/test_readers/test_python/showtok deleted file mode 100755 index efd250ce1..000000000 --- a/docutils/test/test_readers/test_python/showtok +++ /dev/null @@ -1,40 +0,0 @@ -#! /usr/bin/env python - - -""" -This is a tool for exploring token lists generated by -``tokenize.generate_tokens()`` from test data in -docutils/test/test_readers/test_python/test_parser or stdin. - -Usage:: - - showtok <key> <index> - - showtok < <module.py> - -Where ``<key>`` is the key to the ``totest`` dictionary, and ``<index>`` is -the index of the list ``totest[key]``. If no arguments are given, stdin is -used for input. -""" - -import sys -import tokenize -import pprint -from token import tok_name -import test_parser - -def name_tokens(tokens): - for i in range(len(tokens)): - tup = tokens[i] - tokens[i] = (tok_name[tup[0]], tup) - -if len(sys.argv) > 1: - key, caseno = sys.argv[1:] - print 'totest["%s"][%s][0]:\n' % (key, caseno) - input_text = test_parser.totest[key][int(caseno)][0] -else: - input_text = sys.stdin.read() -print input_text -tokens = list(tokenize.generate_tokens(iter(input_text.splitlines(1)).next)) -name_tokens(tokens) -pprint.pprint(tokens) diff --git a/docutils/test/test_readers/test_python/test_functions.py b/docutils/test/test_readers/test_python/test_functions.py deleted file mode 100644 index d521b2203..000000000 --- a/docutils/test/test_readers/test_python/test_functions.py +++ /dev/null @@ -1,56 +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 PySource Reader functions. -""" - -import unittest -from __init__ import DocutilsTestSupport -from docutils.readers.python.moduleparser import trim_docstring - - -class MiscTests(unittest.TestCase): - - docstrings = ( - ("""""", """"""), # empty - ("""Begins on the first line. - - Middle line indented. - - Last line unindented. - """, - """\ -Begins on the first line. - - Middle line indented. - -Last line unindented."""), - (""" - Begins on the second line. - - Middle line indented. - - Last line unindented.""", - """\ -Begins on the second line. - - Middle line indented. - -Last line unindented."""), - ("""All on one line.""", """All on one line.""")) - - def test_trim_docstring(self): - for docstring, expected in self.docstrings: - self.assertEquals(trim_docstring(docstring), expected) - self.assertEquals(trim_docstring('\n ' + docstring), - expected) - - -if __name__ == '__main__': - unittest.main() diff --git a/docutils/test/test_readers/test_python/test_parser.py b/docutils/test/test_readers/test_python/test_parser.py deleted file mode 100644 index ce70cc27c..000000000 --- a/docutils/test/test_readers/test_python/test_parser.py +++ /dev/null @@ -1,745 +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/readers/python/moduleparser.py. -""" - -from __init__ import DocutilsTestSupport - - -def suite(): - s = DocutilsTestSupport.PythonModuleParserTestSuite() - s.generateTests(totest) - return s - -totest = {} - -totest['module'] = [ -['''\ -''', -'''\ -<Module filename="test data"> -'''], -['''\ -"""docstring""" -''', -'''\ -<Module filename="test data"> - <Docstring> - docstring -'''], -['''\ -u"""Unicode docstring""" -''', -'''\ -<Module filename="test data"> - <Docstring> - Unicode docstring -'''], -['''\ -"""docstring""" -"""additional docstring""" -''', -'''\ -<Module filename="test data"> - <Docstring> - docstring - <Docstring lineno="2"> - additional docstring -'''], -['''\ -"""docstring""" -# comment -"""additional docstring""" -''', -'''\ -<Module filename="test data"> - <Docstring> - docstring - <Docstring lineno="3"> - additional docstring -'''], -['''\ -"""docstring""" -1 -"""not an additional docstring""" -''', -'''\ -<Module filename="test data"> - <Docstring> - docstring -'''], -] - -totest['import'] = [ -['''\ -import module -''', -'''\ -<Module filename="test data"> - <Import lineno="1"> - module -'''], -['''\ -import module as local -''', -'''\ -<Module filename="test data"> - <Import lineno="1"> - module as local -'''], -['''\ -import module.name -''', -'''\ -<Module filename="test data"> - <Import lineno="1"> - module.name -'''], -['''\ -import module.name as local -''', -'''\ -<Module filename="test data"> - <Import lineno="1"> - module.name as local -'''], -['''\ -import module -"""not documentable""" -''', -'''\ -<Module filename="test data"> - <Import lineno="1"> - module -'''], -] - -totest['from'] = [ -['''\ -from module import name -''', -'''\ -<Module filename="test data"> - <Import from="module" lineno="1"> - name -'''], -['''\ -from module import name as local -''', -'''\ -<Module filename="test data"> - <Import from="module" lineno="1"> - name as local -'''], -['''\ -from module import name1, name2 as local2 -''', -'''\ -<Module filename="test data"> - <Import from="module" lineno="1"> - name1 - name2 as local2 -'''], -['''\ -from module.sub import name -''', -'''\ -<Module filename="test data"> - <Import from="module.sub" lineno="1"> - name -'''], -['''\ -from module.sub import name as local -''', -'''\ -<Module filename="test data"> - <Import from="module.sub" lineno="1"> - name as local -'''], -['''\ -from module import * -''', -'''\ -<Module filename="test data"> - <Import from="module" lineno="1"> - * -'''], -['''\ -from __future__ import division -''', -'''\ -<Module filename="test data"> - <Import from="__future__" lineno="1"> - division -'''], -] - -totest['assign'] = [ -['''\ -a = 1 -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - 1 -'''], -['''a = 1''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - 1 -'''], -['''\ -a = 1 -"""a's docstring""" -''', #" -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - 1 - <Docstring lineno="2"> - a's docstring -'''], #' -['''\ -a = 1 -"""a's docstring""" -"""additional docstring""" -''', #" -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - 1 - <Docstring lineno="2"> - a's docstring - <Docstring lineno="3"> - additional docstring -'''], #' -['''\ -a = 1 + 2 * 3 / 4 ** 5 -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - 1 + 2 * 3 / 4 ** 5 -'''], -['''\ -a = 1 \\ - + 2 -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - 1 + 2 -'''], -['''\ -a = not 1 and 2 or 3 -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - not 1 and 2 or 3 -'''], -['''\ -a = ~ 1 & 2 | 3 ^ 4 -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - ~ 1 & 2 | 3 ^ 4 -'''], -['''\ -a = `1 & 2` -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - `1 & 2` -'''], -['''\ -very_long_name = \\ - x -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="very_long_name"> - <Expression lineno="1"> - x -'''], -['''\ -very_long_name \\ - = x -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="very_long_name"> - <Expression lineno="2"> - x -'''], -['''\ -very_long_name = \\ - another_long_name = \\ - x -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="very_long_name"> - <Expression lineno="1"> - x - <Attribute lineno="2" name="another_long_name"> - <Expression lineno="1"> - x -'''], -['''\ -a = (1 - + 2) -b = a.b[1 + - fn(x, y, - z, {'key': (1 + 2 - + 3)})][4] -c = """first line -second line - third""" -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - (1 + 2) - <Attribute lineno="3" name="b"> - <Expression lineno="3"> - a.b[1 + fn(x, y, z, {'key': (1 + 2 + 3)})][4] - <Attribute lineno="7" name="c"> - <Expression lineno="7"> - """first line\\nsecond line\\n third""" -'''], -['''\ -a, b, c = range(3) -(d, e, - f) = a, b, c -g, h, i = j = a, b, c -k.a, k.b.c, k.d.e.f = a, b, c -''', -'''\ -<Module filename="test data"> - <AttributeTuple lineno="1" names="a b c"> - <Expression lineno="1"> - range(3) - <AttributeTuple lineno="2" names="d e f"> - <Expression lineno="3"> - a, b, c - <AttributeTuple lineno="4" names="g h i"> - <Expression lineno="4"> - a, b, c - <Attribute lineno="4" name="j"> - <Expression lineno="4"> - a, b, c - <AttributeTuple lineno="5" names="k.a k.b.c k.d.e.f"> - <Expression lineno="5"> - a, b, c -'''], -['''\ -a = 1 ; b = 2 -print ; c = 3 -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - 1 - <Attribute lineno="1" name="b"> - <Expression lineno="1"> - 2 - <Attribute lineno="2" name="c"> - <Expression lineno="2"> - 3 -'''], -['''\ -a.b = 1 -"""This assignment is noted but ignored unless ``a`` is a function.""" -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a.b"> - <Expression lineno="1"> - 1 - <Docstring lineno="2"> - This assignment is noted but ignored unless ``a`` is a function. -'''], -['''\ -a[b] = 1 -"""Subscript assignments are ignored.""" -''', -'''\ -<Module filename="test data"> -'''], -['''\ -a = foo(b=1) -''', -'''\ -<Module filename="test data"> - <Attribute lineno="1" name="a"> - <Expression lineno="1"> - foo(b=1) -'''], -# ['''\ -# a = 1 -# -# """Because of the blank above, this is a module docstring.""" -# ''', -# '''\ -# <Module filename="test data"> -# <Attribute lineno="1" name="a"> -# <Expression lineno="1"> -# 1 -# <Docstring lineno="3"> -# Because of the blank above, this is a module docstring. -# '''], -] - -totest['def'] = [ -['''\ -def f(): - """Function f's docstring""" - """Additional docstring""" - local = 1 - """Not a docstring, since ``local`` is local.""" -''', # " -'''\ -<Module filename="test data"> - <Function lineno="1" name="f"> - <Docstring lineno="1"> - Function f's docstring - <Docstring lineno="3"> - Additional docstring -'''], # ' -['''\ -def f(a, b): - local = 1 -''', -'''\ -<Module filename="test data"> - <Function lineno="1" name="f"> - <ParameterList lineno="1"> - <Parameter lineno="1" name="a"> - <Parameter lineno="1" name="b"> -'''], -['''\ -def f(a=None, b=1): - local = 1 -''', -'''\ -<Module filename="test data"> - <Function lineno="1" name="f"> - <ParameterList lineno="1"> - <Parameter lineno="1" name="a"> - <Default lineno="1"> - None - <Parameter lineno="1" name="b"> - <Default lineno="1"> - 1 -'''], -['''\ -def f(a, (b, c, d)=range(3), - e=None): - local = 1 -''', -'''\ -<Module filename="test data"> - <Function lineno="1" name="f"> - <ParameterList lineno="1"> - <Parameter lineno="1" name="a"> - <ParameterTuple lineno="1" names="(b, c, d)"> - <Default lineno="1"> - range(3) - <Parameter lineno="1" name="e"> - <Default lineno="1"> - None -'''], -['''\ -def f(*args): - local = 1 -''', -'''\ -<Module filename="test data"> - <Function lineno="1" name="f"> - <ParameterList lineno="1"> - <ExcessPositionalArguments lineno="1" name="args"> -'''], -['''\ -def f(**kwargs): - local = 1 -''', -'''\ -<Module filename="test data"> - <Function lineno="1" name="f"> - <ParameterList lineno="1"> - <ExcessKeywordArguments lineno="1" name="kwargs"> -'''], -['''\ -def f(a, b=None, *args, **kwargs): - local = 1 -''', -'''\ -<Module filename="test data"> - <Function lineno="1" name="f"> - <ParameterList lineno="1"> - <Parameter lineno="1" name="a"> - <Parameter lineno="1" name="b"> - <Default lineno="1"> - None - <ExcessPositionalArguments lineno="1" name="args"> - <ExcessKeywordArguments lineno="1" name="kwargs"> -'''], -['''\ -def f(): - pass -f.attrib = 1 -"""f.attrib's docstring""" -''', # " -# @@@ When should the Attribute move inside the Function? -'''\ -<Module filename="test data"> - <Function lineno="1" name="f"> - <Attribute lineno="3" name="f.attrib"> - <Expression lineno="3"> - 1 - <Docstring lineno="4"> - f.attrib's docstring -'''], # ' -['''\ -def f(): - def g(): - pass - """Not a docstring""" - local = 1 -''', -'''\ -<Module filename="test data"> - <Function lineno="1" name="f"> -'''], -] - -totest['class'] = [ -['''\ -class C: - """class C's docstring""" -''', -'''\ -<Module filename="test data"> - <Class lineno="1" name="C"> - <Docstring lineno="1"> - class C's docstring -'''], -['''\ -class C(Super): - pass - -class D(SuperD, package.module.SuperD): - pass -''', -'''\ -<Module filename="test data"> - <Class bases="Super" lineno="1" name="C"> - <Class bases="SuperD package.module.SuperD" lineno="4" name="D"> -'''], -['''\ -class C: - class D: - pass - """Not a docstring""" -''', -'''\ -<Module filename="test data"> - <Class lineno="1" name="C"> -'''], -['''\ -class C: - def f(self): - self.local = 1 - local = 1 -''', -'''\ -<Module filename="test data"> - <Class lineno="1" name="C"> - <Method lineno="2" name="f"> - <ParameterList lineno="2"> - <Parameter lineno="2" name="self"> -'''], -['''\ -class C: - def __init__(self): - self.local = 1 - local = 1 -''', -'''\ -<Module filename="test data"> - <Class lineno="1" name="C"> - <Method lineno="2" name="__init__"> - <ParameterList lineno="2"> - <Parameter lineno="2" name="self"> - <Attribute lineno="3" name="self.local"> - <Expression lineno="3"> - 1 - <Attribute lineno="4" name="local"> - <Expression lineno="4"> - 1 -'''], -['''\ -class C: - def __init__(self): - local = foo(a=1) -''', -'''\ -<Module filename="test data"> - <Class lineno="1" name="C"> - <Method lineno="2" name="__init__"> - <ParameterList lineno="2"> - <Parameter lineno="2" name="self"> - <Attribute lineno="3" name="local"> - <Expression lineno="3"> - foo(a=1) -'''], -] - -totest['ignore'] = [ -['''\ -1 + 2 -''', -'''\ -<Module filename="test data"> -'''], -['''\ -del a -''', -'''\ -<Module filename="test data"> -'''], -] - -totest['comments'] = [ -# ['''\ -# # Comment -# ''', -# '''\ -# <Module filename="test data"> -# <Comment lineno="1"> -# # Comment -# '''], -] - -# @@@ no comments yet -totest['everything'] = [ -['''\ -# comment - -"""Docstring""" - -"""Additional docstring""" - -__docformat__ = 'reStructuredText' - -a = 1 -"""Attribute docstring""" - -class C(Super): - - """C's docstring""" - - class_attribute = 1 - """class_attribute's docstring""" - - def __init__(self, text=None): - """__init__'s docstring""" - - self.instance_attribute = (text * 7 - + ' whaddyaknow') - """instance_attribute's docstring""" - - -def f(x, # parameter x - y=a*5, # parameter y - *args): # parameter args - """f's docstring""" - return [x + item for item in args] - -f.function_attribute = 1 -"""f.function_attribute's docstring""" -''', -'''\ -<Module filename="test data"> - <Docstring> - Docstring - <Docstring lineno="5"> - Additional docstring - <Attribute lineno="7" name="__docformat__"> - <Expression lineno="7"> - 'reStructuredText' - <Attribute lineno="9" name="a"> - <Expression lineno="9"> - 1 - <Docstring lineno="10"> - Attribute docstring - <Class bases="Super" lineno="12" name="C"> - <Docstring lineno="12"> - C's docstring - <Attribute lineno="16" name="class_attribute"> - <Expression lineno="16"> - 1 - <Docstring lineno="17"> - class_attribute's docstring - <Method lineno="19" name="__init__"> - <Docstring lineno="19"> - __init__'s docstring - <ParameterList lineno="19"> - <Parameter lineno="19" name="self"> - <Parameter lineno="19" name="text"> - <Default lineno="19"> - None - <Attribute lineno="22" name="self.instance_attribute"> - <Expression lineno="22"> - (text * 7 + ' whaddyaknow') - <Docstring lineno="24"> - instance_attribute's docstring - <Function lineno="27" name="f"> - <Docstring lineno="27"> - f's docstring - <ParameterList lineno="27"> - <Parameter lineno="27" name="x"> - <Parameter lineno="27" name="y"> - <Default lineno="27"> - a * 5 - <ExcessPositionalArguments lineno="27" name="args"> - <Attribute lineno="33" name="f.function_attribute"> - <Expression lineno="33"> - 1 - <Docstring lineno="34"> - f.function_attribute's docstring -'''], -] - -""" -['''\ -''', -'''\ -'''], -""" - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_readers/test_python/test_token_parser.py b/docutils/test/test_readers/test_python/test_token_parser.py deleted file mode 100644 index 23015a7dc..000000000 --- a/docutils/test/test_readers/test_python/test_token_parser.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/readers/python/moduleparser.py. -""" - -from __init__ import DocutilsTestSupport - - -def suite(): - s = DocutilsTestSupport.PythonModuleParserTestSuite() - s.generateTests(totest, testmethod='test_token_parser_rhs') - return s - -totest = {} - -totest['expressions'] = [ -['''a = 1''', '''1'''], -['''a = b = 1''', '''1'''], -['''\ -a = ( - 1 + 2 - + 3 - ) -''', -'''(1 + 2 + 3)'''], -['''\ -a = """\\ -line one -line two""" -''', -'''"""\\\nline one\nline two"""'''], -['''a = `1`''', '''`1`'''], -['''a = `1`+`2`''', '''`1` + `2`'''], -] - - -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 4ca2a0144..000000000 --- a/docutils/test/test_statemachine.py +++ /dev/null @@ -1,283 +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 -import sys -import re -from DocutilsTestSupport import statemachine - - -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 known_indent1 ' - 'StateMachine2 text2 text2 blank2 text2 blank2 indent2 ' - 'StateMachine3 text3 blank3 finished3 finished2 ' - 'bullet1 known_indent1 ' - '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': ''} - initial_transitions = ['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, next_state): - 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, next_state): - if self.debug: print >>sys.stderr, 'indent%s' % self.level - context, next_state, result = statemachine.StateWS.indent( - self, match, context, next_state) - return context, next_state, ['indent%s' % self.level] + result - - def known_indent(self, match, context, next_state): - if self.debug: print >>sys.stderr, 'known_indent%s' % self.level - context, next_state, result = statemachine.StateWS.known_indent( - self, match, context, next_state) - return context, next_state, ['known_indent%s' % self.level] + result - - def bullet(self, match, context, next_state): - if self.debug: print >>sys.stderr, 'bullet%s' % self.level - context, next_state, result \ - = self.known_indent(match, context, next_state) - return [], next_state, ['bullet%s' % self.level] + result - - def text(self, match, context, next_state): - if self.debug: print >>sys.stderr, 'text%s' % self.level - return [match.string], next_state, ['text%s' % self.level] - - def literalblock(self): - indented, indent, offset, good = self.state_machine.get_indented() - 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( - state_classes=[], initial_state='State') - self.sm.debug = debug - - def test_add_state(self): - self.sm.add_state(statemachine.State) - self.assert_(len(self.sm.states) == 1) - self.assertRaises(statemachine.DuplicateStateError, self.sm.add_state, - statemachine.State) - self.sm.add_state(statemachine.StateWS) - self.assert_(len(self.sm.states) == 2) - - def test_add_states(self): - self.sm.add_states((statemachine.State, statemachine.StateWS)) - self.assertEqual(len(self.sm.states), 2) - - def test_get_state(self): - self.assertRaises(statemachine.UnknownStateError, self.sm.get_state) - self.sm.add_states((statemachine.State, statemachine.StateWS)) - self.assertRaises(statemachine.UnknownStateError, self.sm.get_state, - 'unknownState') - self.assert_(isinstance(self.sm.get_state('State'), - statemachine.State)) - self.assert_(isinstance(self.sm.get_state('StateWS'), - statemachine.State)) - self.assertEqual(self.sm.current_state, 'StateWS') - - -class EmptySMWSTests(EmptySMTests): - - def setUp(self): - self.sm = statemachine.StateMachineWS( - state_classes=[], initial_state='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), 4) - - def test_get_indented(self): - self.sm.input_lines = statemachine.StringList(testtext) - self.sm.line_offset = -1 - self.sm.next_line(3) - indented, offset, good = self.sm.get_known_indented(2) - self.assertEquals(indented, item1) - self.assertEquals(offset, len(para1)) - self.failUnless(good) - self.sm.next_line() - indented, offset, good = self.sm.get_known_indented(2) - self.assertEquals(indented, item2) - self.assertEquals(offset, len(para1) + len(item1)) - self.failUnless(good) - self.sm.previous_line(3) - if self.sm.debug: - print '\ntest_get_indented: self.sm.line:\n', self.sm.line - indented, indent, offset, good = self.sm.get_indented() - if self.sm.debug: - print '\ntest_get_indented: 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_get_text_block(self): - self.sm.input_lines = statemachine.StringList(testtext) - self.sm.line_offset = -1 - self.sm.next_line() - textblock = self.sm.get_text_block() - self.assertEquals(textblock, testtext[:1]) - self.sm.next_line(2) - textblock = self.sm.get_text_block() - self.assertEquals(textblock, testtext[2:4]) - - def test_get_text_block_flush_left(self): - self.sm.input_lines = statemachine.StringList(testtext) - self.sm.line_offset = -1 - self.sm.next_line() - textblock = self.sm.get_text_block(flush_left=1) - self.assertEquals(textblock, testtext[:1]) - self.sm.next_line(2) - self.assertRaises(statemachine.UnexpectedIndentationError, - self.sm.get_text_block, flush_left=1) - - 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_add_transitions(self): - self.assertEquals(len(self.state.transitions), 0) - self.state.add_transitions(['None'], {'None': None}) - self.assertEquals(len(self.state.transitions), 1) - self.assertRaises(statemachine.UnknownTransitionError, - self.state.add_transitions, ['bogus'], {}) - self.assertRaises(statemachine.DuplicateTransitionError, - self.state.add_transitions, ['None'], - {'None': None}) - - def test_add_transition(self): - self.assertEquals(len(self.state.transitions), 0) - self.state.add_transition('None', None) - self.assertEquals(len(self.state.transitions), 1) - self.assertRaises(statemachine.DuplicateTransitionError, - self.state.add_transition, 'None', None) - - def test_remove_transition(self): - self.assertEquals(len(self.state.transitions), 0) - self.state.add_transition('None', None) - self.assertEquals(len(self.state.transitions), 1) - self.state.remove_transition('None') - self.assertEquals(len(self.state.transitions), 0) - self.assertRaises(statemachine.UnknownTransitionError, - self.state.remove_transition, 'None') - - def test_make_transition(self): - dummy = re.compile('dummy') - self.assertEquals(self.state.make_transition('nop', 'bogus'), - (dummy, self.state.nop, 'bogus')) - self.assertEquals(self.state.make_transition('nop'), - (dummy, self.state.nop, - self.state.__class__.__name__)) - self.assertRaises(statemachine.TransitionPatternNotFound, - self.state.make_transition, 'None') - self.assertRaises(statemachine.TransitionMethodNotFound, - self.state.make_transition, 'bogus') - - def test_make_transitions(self): - dummy = re.compile('dummy') - self.assertEquals(self.state.make_transitions(('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."] - def test_string2lines(self): - self.assertEquals(statemachine.string2lines(self.s2l_string), - self.s2l_expected) - - -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 2fe79c55c..000000000 --- a/docutils/test/test_transforms/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import os.path -import sys - -sys.path.insert(0, os.path.abspath(os.curdir)) -prev = '' -while sys.path[0] != prev: - try: - import DocutilsTestSupport - break - except ImportError: - prev = sys.path[0] - sys.path[0] = os.path.dirname(prev) -sys.path.pop(0) diff --git a/docutils/test/test_transforms/test_class.py b/docutils/test/test_transforms/test_class.py deleted file mode 100755 index db5a1cbdf..000000000 --- a/docutils/test/test_transforms/test_class.py +++ /dev/null @@ -1,104 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for `docutils.transforms.misc.ClassAttribute`. -""" - -from __init__ import DocutilsTestSupport -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['tables_of_contents'] = ((), [ -["""\ -.. class:: one - -paragraph -""", -"""\ -<document source="test data"> - <paragraph class="one"> - paragraph -"""], -["""\ -.. class:: two -.. - - Block quote -""", -"""\ -<document source="test data"> - <comment xml:space="preserve"> - <block_quote class="two"> - <paragraph> - Block quote -"""], -["""\ - Block quote - - .. class:: three - -Paragraph -""", -"""\ -<document source="test data"> - <block_quote> - <paragraph> - Block quote - <paragraph class="three"> - Paragraph -"""], -["""\ -.. class:: four - -Section Title -============= - -Paragraph -""", -"""\ -<document source="test data"> - <section class="four" id="section-title" name="section title"> - <title> - Section Title - <paragraph> - Paragraph -"""], -["""\ -.. class:: - -.. class:: 99 -""", -"""\ -<document source="test data"> - <system_message level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Error in "class" directive: - 1 argument(s) required, 0 supplied. - <literal_block xml:space="preserve"> - .. class:: - <system_message level="3" line="3" source="test data" type="ERROR"> - <paragraph> - Invalid class attribute value for "class" directive: 99 - <literal_block xml:space="preserve"> - .. class:: 99 -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_contents.py b/docutils/test/test_transforms/test_contents.py deleted file mode 100755 index 5f54e7a74..000000000 --- a/docutils/test/test_transforms/test_contents.py +++ /dev/null @@ -1,377 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for `docutils.transforms.parts.Contents` (via -`docutils.transforms.universal.LastReaderPending`). -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import Substitutions -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['tables_of_contents'] = ((Substitutions,), [ -["""\ -.. contents:: - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -"""\ -<document source="test data"> - <topic class="contents" id="contents" name="contents"> - <title> - Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - Title 1 - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - Title 2 - <bullet_list> - <list_item> - <paragraph> - <reference id="id3" refid="title-3"> - Title 3 - <list_item> - <paragraph> - <reference id="id4" refid="title-4"> - Title 4 - <section id="title-1" name="title 1"> - <title refid="id1"> - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id2"> - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title refid="id3"> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title refid="id4"> - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -.. contents:: Table of Contents - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. -""", -"""\ -<document source="test data"> - <topic class="contents" id="table-of-contents" name="table of contents"> - <title> - Table of Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - Title 1 - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - Title 2 - <section id="title-1" name="title 1"> - <title refid="id1"> - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id2"> - Title 2 - <paragraph> - Paragraph 2. -"""], -["""\ -.. contents:: There's an image in Title 2 - -Title 1 -======= -Paragraph 1. - -|Title 2| -========= -Paragraph 2. - -.. |Title 2| image:: title2.png -""", -"""\ -<document source="test data"> - <topic class="contents" id="there-s-an-image-in-title-2" name="there's an image in title 2"> - <title> - There's an image in Title 2 - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - Title 1 - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - Title 2 - <section id="title-1" name="title 1"> - <title refid="id1"> - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id2"> - <image alt="Title 2" uri="title2.png"> - <paragraph> - Paragraph 2. - <substitution_definition name="Title 2"> - <image alt="Title 2" uri="title2.png"> -"""], # emacs cruft: " -["""\ -.. contents:: - :depth: 2 - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -"""\ -<document source="test data"> - <topic class="contents" id="contents" name="contents"> - <title> - Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - Title 1 - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - Title 2 - <list_item> - <paragraph> - <reference id="id3" refid="title-4"> - Title 4 - <section id="title-1" name="title 1"> - <title refid="id1"> - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id2"> - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title refid="id3"> - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -Title 1 -======= - -.. contents:: - :local: - -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -"""\ -<document source="test data"> - <section id="title-1" name="title 1"> - <title> - Title 1 - <topic class="contents" id="contents" name="contents"> - <bullet_list> - <list_item> - <paragraph> - <reference id="id1" refid="title-2"> - Title 2 - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="title-3"> - Title 3 - <list_item> - <paragraph> - <reference id="id3" refid="title-4"> - Title 4 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title refid="id1"> - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title refid="id2"> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title refid="id3"> - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -.. contents:: - :local: - -Test duplicate name "Contents". - -Contents --------- -Paragraph. -""", -"""\ -<document source="test data"> - <topic class="contents" id="id1"> - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="contents"> - Contents - <paragraph> - Test duplicate name "Contents". - <section id="contents" name="contents"> - <title refid="id2"> - Contents - <paragraph> - Paragraph. -"""], -["""\ -.. contents:: - :backlinks: top - -Contents --------- -Paragraph. -""", -"""\ -<document source="test data"> - <topic class="contents" id="id1"> - <title> - Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="contents"> - Contents - <section id="contents" name="contents"> - <title refid="id1"> - Contents - <paragraph> - Paragraph. -"""], -["""\ -.. contents:: - :backlinks: none - -Contents --------- -Paragraph. -""", -"""\ -<document source="test data"> - <topic class="contents" id="id1"> - <title> - Contents - <bullet_list> - <list_item> - <paragraph> - <reference id="id2" refid="contents"> - Contents - <section id="contents" name="contents"> - <title> - Contents - <paragraph> - Paragraph. -"""], -["""\ -.. contents:: - -Degenerate case, no table of contents generated. -""", -"""\ -<document source="test data"> - <paragraph> - Degenerate case, no table of contents generated. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_docinfo.py b/docutils/test/test_transforms/test_docinfo.py deleted file mode 100755 index 9fafa4ccb..000000000 --- a/docutils/test/test_transforms/test_docinfo.py +++ /dev/null @@ -1,336 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for docutils.transforms.frontmatter.DocInfo. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.frontmatter import DocInfo -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['bibliographic_field_lists'] = ((DocInfo,), [ -["""\ -.. Bibliographic element extraction. - -:Abstract: - There can only be one abstract. - - It is automatically moved to the end of the other bibliographic elements. - -:Author: Me -:Version: 1 -:Date: 2001-08-11 -:Parameter i: integer -""", -"""\ -<document source="test data"> - <docinfo> - <author> - Me - <version> - 1 - <date> - 2001-08-11 - <field> - <field_name> - Parameter i - <field_body> - <paragraph> - integer - <topic class="abstract"> - <title> - Abstract - <paragraph> - There can only be one abstract. - <paragraph> - It is automatically moved to the end of the other bibliographic elements. - <comment xml:space="preserve"> - Bibliographic element extraction. -"""], -["""\ -.. Bibliographic element extraction. - -:Abstract: Abstract 1. -:Author: Me -:Address: 123 My Street - Example, EX -:Contact: me@my.org -:Version: 1 -:Abstract: Abstract 2 (should generate a warning). -:Date: 2001-08-11 -:Parameter i: integer -""", -"""\ -<document source="test data"> - <docinfo> - <author> - Me - <address xml:space="preserve"> - 123 My Street - Example, EX - <contact> - <reference refuri="mailto:me@my.org"> - me@my.org - <version> - 1 - <field> - <field_name> - Abstract - <field_body> - <paragraph> - Abstract 2 (should generate a warning). - <system_message level="2" line="9" source="test data" type="WARNING"> - <paragraph> - There can only be one "Abstract" field. - <date> - 2001-08-11 - <field> - <field_name> - Parameter i - <field_body> - <paragraph> - integer - <topic class="abstract"> - <title> - Abstract - <paragraph> - Abstract 1. - <comment xml:space="preserve"> - Bibliographic element extraction. -"""], -["""\ -:Author: - must be a paragraph -:Status: a *simple* paragraph -:Date: But only one - - paragraph. -:Version: - -.. and not empty either -""", -"""\ -<document source="test data"> - <docinfo> - <field> - <field_name> - Author - <field_body> - <bullet_list bullet="-"> - <list_item> - <paragraph> - must be a paragraph - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Cannot extract bibliographic field "Author" containing anything other than a single paragraph. - <status> - a \n\ - <emphasis> - simple - paragraph - <field> - <field_name> - Date - <field_body> - <paragraph> - But only one - <paragraph> - paragraph. - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Cannot extract compound bibliographic field "Date". - <field> - <field_name> - Version - <field_body> - <system_message level="2" line="6" source="test data" type="WARNING"> - <paragraph> - Cannot extract empty bibliographic field "Version". - <comment xml:space="preserve"> - and not empty either -"""], -["""\ -:Authors: Me, Myself, **I** -:Authors: PacMan; Ms. PacMan; PacMan, Jr. -:Authors: - Here - - There - - *Everywhere* -:Authors: - First - - Second - - Third -""", -"""\ -<document source="test data"> - <docinfo> - <authors> - <author> - Me - <author> - Myself - <author> - I - <authors> - <author> - PacMan - <author> - Ms. PacMan - <author> - PacMan, Jr. - <authors> - <author> - Here - <author> - There - <author> - <emphasis> - Everywhere - <authors> - <author> - First - <author> - Second - <author> - Third -"""], -["""\ -:Authors: Only One -:Authors: One, Only; -""", -"""\ -<document source="test data"> - <docinfo> - <author> - Only One - <author> - One, Only -"""], -["""\ -:Authors: - -:Authors: 1. One - 2. Two - -:Authors: - - - - - -:Authors: - - One - - Two - -:Authors: - - One - - Two -""", -"""\ -<document source="test data"> - <docinfo> - <field> - <field_name> - Authors - <field_body> - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Cannot extract empty bibliographic field "Authors". - <field> - <field_name> - Authors - <field_body> - <enumerated_list enumtype="arabic" prefix="" suffix="."> - <list_item> - <paragraph> - One - <list_item> - <paragraph> - Two - <system_message level="2" line="3" source="test data" type="WARNING"> - <paragraph> - Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item. - <field> - <field_name> - Authors - <field_body> - <bullet_list bullet="-"> - <list_item> - <list_item> - <system_message level="2" line="6" source="test data" type="WARNING"> - <paragraph> - Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item. - <field> - <field_name> - Authors - <field_body> - <bullet_list bullet="-"> - <list_item> - <paragraph> - One - <paragraph> - Two - <system_message level="2" line="10" source="test data" type="WARNING"> - <paragraph> - Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item. - <field> - <field_name> - Authors - <field_body> - <bullet_list bullet="-"> - <list_item> - <paragraph> - One - <paragraph> - Two - <system_message level="2" line="15" source="test data" type="WARNING"> - <paragraph> - Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item. -"""], -["""\ -.. RCS keyword extraction. - -:Status: $RCSfile$ -:Date: $Date$ - -RCS keyword 'RCSfile' doesn't change unless the file name changes, -so it's safe. The 'Date' keyword changes every time the file is -checked in to CVS, so the test's expected output text has to be -derived (hacked) in parallel in order to stay in sync. -""", -"""\ -<document source="test data"> - <docinfo> - <status> - test_docinfo.py - <date> - %s - <comment xml:space="preserve"> - RCS keyword extraction. - <paragraph> - RCS keyword 'RCSfile' doesn't change unless the file name changes, - so it's safe. The 'Date' keyword changes every time the file is - checked in to CVS, so the test's expected output text has to be - derived (hacked) in parallel in order to stay in sync. -""" % ('$Date$'[7:17].replace('/', '-'),)], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_doctitle.py b/docutils/test/test_transforms/test_doctitle.py deleted file mode 100755 index 3e08eb232..000000000 --- a/docutils/test/test_transforms/test_doctitle.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for docutils.transforms.frontmatter.DocTitle. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.frontmatter import DocTitle -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['section_headers'] = ((DocTitle,), [ -["""\ -.. test title promotion - -Title -===== - -Paragraph. -""", -"""\ -<document id="title" name="title" source="test data"> - <title> - Title - <comment xml:space="preserve"> - test title promotion - <paragraph> - Paragraph. -"""], -["""\ -Title -===== -Paragraph (no blank line). -""", -"""\ -<document id="title" name="title" source="test data"> - <title> - Title - <paragraph> - Paragraph (no blank line). -"""], -["""\ -Paragraph. - -Title -===== - -Paragraph. -""", -"""\ -<document source="test data"> - <paragraph> - Paragraph. - <section id="title" name="title"> - <title> - Title - <paragraph> - Paragraph. -"""], -["""\ -Title -===== - -Subtitle --------- - -Test title & subtitle. -""", -"""\ -<document id="title" name="title" source="test data"> - <title> - Title - <subtitle id="subtitle" name="subtitle"> - Subtitle - <paragraph> - Test title & subtitle. -"""], -["""\ -Title -==== - -Test short underline. -""", -"""\ -<document id="title" name="title" source="test data"> - <title> - Title - <system_message level="2" line="2" source="test data" type="WARNING"> - <paragraph> - Title underline too short. - <literal_block xml:space="preserve"> - Title - ==== - <paragraph> - Test short underline. -"""], -["""\ -======= - Long Title -======= - -Test long title and space normalization. -The system_message should move after the document title -(it was before the beginning of the section). -""", -"""\ -<document id="long-title" name="long title" source="test data"> - <title> - Long Title - <system_message level="2" line="1" source="test data" type="WARNING"> - <paragraph> - Title overline too short. - <literal_block xml:space="preserve"> - ======= - Long Title - ======= - <paragraph> - Test long title and space normalization. - The system_message should move after the document title - (it was before the beginning of the section). -"""], -["""\ -.. Test multiple second-level titles. - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -------- -Paragraph 3. -""", -"""\ -<document id="title-1" name="title 1" source="test data"> - <title> - Title 1 - <comment xml:space="preserve"> - Test multiple second-level titles. - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title> - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title> - Title 3 - <paragraph> - Paragraph 3. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_filter.py b/docutils/test/test_transforms/test_filter.py deleted file mode 100644 index 009600d81..000000000 --- a/docutils/test/test_transforms/test_filter.py +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for docutils.transforms.components.Filter. -""" - -from __init__ import DocutilsTestSupport -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['meta'] = ((), [ -["""\ -.. meta:: - :description: The reStructuredText plaintext markup language - :keywords: plaintext,markup language -""", -"""\ -<document source="test data"> - <meta content="The reStructuredText plaintext markup language" name="description"> - <meta content="plaintext,markup language" name="keywords"> -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_final_checks.py b/docutils/test/test_transforms/test_final_checks.py deleted file mode 100755 index 36c55efda..000000000 --- a/docutils/test/test_transforms/test_final_checks.py +++ /dev/null @@ -1,46 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for docutils.transforms.universal.FinalChecks. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.universal import FinalChecks -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['final_checks'] = ((FinalChecks,), [ -["""\ -Unknown reference_. -""", -"""\ -<document source="test data"> - <paragraph> - Unknown \n\ - <problematic id="id2" refid="id1"> - reference_ - . - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Unknown target name: "reference". -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_footnotes.py b/docutils/test/test_transforms/test_footnotes.py deleted file mode 100755 index 4da43e055..000000000 --- a/docutils/test/test_transforms/test_footnotes.py +++ /dev/null @@ -1,520 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for docutils.transforms.references.Footnotes. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import Footnotes -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['footnotes'] = ((Footnotes,), [ -["""\ -[#autolabel]_ - -.. [#autolabel] text -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference auto="1" id="id1" refid="autolabel"> - 1 - <footnote auto="1" backrefs="id1" id="autolabel" name="autolabel"> - <label> - 1 - <paragraph> - text -"""], -["""\ -autonumber: [#]_ - -.. [#] text -""", -"""\ -<document source="test data"> - <paragraph> - autonumber: \n\ - <footnote_reference auto="1" id="id1" refid="id2"> - 1 - <footnote auto="1" backrefs="id1" id="id2" name="1"> - <label> - 1 - <paragraph> - text -"""], -["""\ -[#]_ is the first auto-numbered footnote reference. -[#]_ is the second auto-numbered footnote reference. - -.. [#] Auto-numbered footnote 1. -.. [#] Auto-numbered footnote 2. -.. [#] Auto-numbered footnote 3. - -[#]_ is the third auto-numbered footnote reference. -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference auto="1" id="id1" refid="id3"> - 1 - is the first auto-numbered footnote reference. - <footnote_reference auto="1" id="id2" refid="id4"> - 2 - is the second auto-numbered footnote reference. - <footnote auto="1" backrefs="id1" id="id3" name="1"> - <label> - 1 - <paragraph> - Auto-numbered footnote 1. - <footnote auto="1" backrefs="id2" id="id4" name="2"> - <label> - 2 - <paragraph> - Auto-numbered footnote 2. - <footnote auto="1" backrefs="id6" id="id5" name="3"> - <label> - 3 - <paragraph> - Auto-numbered footnote 3. - <paragraph> - <footnote_reference auto="1" id="id6" refid="id5"> - 3 - is the third auto-numbered footnote reference. -"""], -["""\ -[#third]_ is a reference to the third auto-numbered footnote. - -.. [#first] First auto-numbered footnote. -.. [#second] Second auto-numbered footnote. -.. [#third] Third auto-numbered footnote. - -[#second]_ is a reference to the second auto-numbered footnote. -[#first]_ is a reference to the first auto-numbered footnote. -[#third]_ is another reference to the third auto-numbered footnote. - -Here are some internal cross-references to the implicit targets -generated by the footnotes: first_, second_, third_. -""", -"""\ -<document source="test data"> - <paragraph> - <footnote_reference auto="1" id="id1" refid="third"> - 3 - is a reference to the third auto-numbered footnote. - <footnote auto="1" backrefs="id3" id="first" name="first"> - <label> - 1 - <paragraph> - First auto-numbered footnote. - <footnote auto="1" backrefs="id2" id="second" name="second"> - <label> - 2 - <paragraph> - Second auto-numbered footnote. - <footnote auto="1" backrefs="id1 id4" id="third" name="third"> - <label> - 3 - <paragraph> - Third auto-numbered footnote. - <paragraph> - <footnote_reference auto="1" id="id2" refid="second"> - 2 - is a reference to the second auto-numbered footnote. - <footnote_reference auto="1" id="id3" refid="first"> - 1 - is a reference to the first auto-numbered footnote. - <footnote_reference auto="1" id="id4" refid="third"> - 3 - is another reference to the third auto-numbered footnote. - <paragraph> - Here are some internal cross-references to the implicit targets - generated by the footnotes: \n\ - <reference refname="first"> - first - , \n\ - <reference refname="second"> - second - , \n\ - <reference refname="third"> - third - . -"""], -["""\ -Mixed anonymous and labelled auto-numbered footnotes: - -[#four]_ should be 4, [#]_ should be 1, -[#]_ should be 3, [#]_ is one too many, -[#two]_ should be 2, and [#six]_ doesn't exist. - -.. [#] Auto-numbered footnote 1. -.. [#two] Auto-numbered footnote 2. -.. [#] Auto-numbered footnote 3. -.. [#four] Auto-numbered footnote 4. -.. [#five] Auto-numbered footnote 5. -.. [#five] Auto-numbered footnote 5 again (duplicate). -""", -"""\ -<document source="test data"> - <paragraph> - Mixed anonymous and labelled auto-numbered footnotes: - <paragraph> - <footnote_reference auto="1" id="id1" refid="four"> - 4 - should be 4, \n\ - <footnote_reference auto="1" id="id2" refid="id7"> - 1 - should be 1, - <footnote_reference auto="1" id="id3" refid="id8"> - 3 - should be 3, \n\ - <problematic id="id11" refid="id10"> - [#]_ - is one too many, - <footnote_reference auto="1" id="id5" refid="two"> - 2 - should be 2, and \n\ - <footnote_reference auto="1" id="id6" refname="six"> - doesn't exist. - <footnote auto="1" backrefs="id2" id="id7" name="1"> - <label> - 1 - <paragraph> - Auto-numbered footnote 1. - <footnote auto="1" backrefs="id5" id="two" name="two"> - <label> - 2 - <paragraph> - Auto-numbered footnote 2. - <footnote auto="1" backrefs="id3" id="id8" name="3"> - <label> - 3 - <paragraph> - Auto-numbered footnote 3. - <footnote auto="1" backrefs="id1" id="four" name="four"> - <label> - 4 - <paragraph> - Auto-numbered footnote 4. - <footnote auto="1" dupname="five" id="five"> - <label> - 5 - <paragraph> - Auto-numbered footnote 5. - <footnote auto="1" dupname="five" id="id9"> - <label> - 6 - <system_message backrefs="id9" level="2" line="12" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "five". - <paragraph> - Auto-numbered footnote 5 again (duplicate). - <system_message backrefs="id11" id="id10" level="3" line="3" source="test data" type="ERROR"> - <paragraph> - Too many autonumbered footnote references: only 2 corresponding footnotes available. -"""], -["""\ -Mixed auto-numbered and manual footnotes: - -.. [1] manually numbered -.. [#] auto-numbered -.. [#label] autonumber-labeled -""", -"""\ -<document source="test data"> - <paragraph> - Mixed auto-numbered and manual footnotes: - <footnote id="id1" name="1"> - <label> - 1 - <paragraph> - manually numbered - <footnote auto="1" id="id2" name="2"> - <label> - 2 - <paragraph> - auto-numbered - <footnote auto="1" id="label" name="label"> - <label> - 3 - <paragraph> - autonumber-labeled -"""], -["""\ -A labeled autonumbered footnote referece: [#footnote]_. - -An unlabeled autonumbered footnote referece: [#]_. - -.. [#] Unlabeled autonumbered footnote. -.. [#footnote] Labeled autonumbered footnote. - Note that the footnotes are not in the same - order as the references. -""", -"""\ -<document source="test data"> - <paragraph> - A labeled autonumbered footnote referece: \n\ - <footnote_reference auto="1" id="id1" refid="footnote"> - 2 - . - <paragraph> - An unlabeled autonumbered footnote referece: \n\ - <footnote_reference auto="1" id="id2" refid="id3"> - 1 - . - <footnote auto="1" backrefs="id2" id="id3" name="1"> - <label> - 1 - <paragraph> - Unlabeled autonumbered footnote. - <footnote auto="1" backrefs="id1" id="footnote" name="footnote"> - <label> - 2 - <paragraph> - Labeled autonumbered footnote. - Note that the footnotes are not in the same - order as the references. -"""], -["""\ -Mixed manually-numbered, anonymous auto-numbered, -and labelled auto-numbered footnotes: - -[#four]_ should be 4, [#]_ should be 2, -[1]_ is 1, [3]_ is 3, -[#]_ should be 6, [#]_ is one too many, -[#five]_ should be 5, and [#eight]_ doesn't exist. - -.. [1] Manually-numbered footnote 1. -.. [#] Auto-numbered footnote 2. -.. [#four] Auto-numbered footnote 4. -.. [3] Manually-numbered footnote 3 -.. [#five] Auto-numbered footnote 5. -.. [#] Auto-numbered footnote 6. -.. [#five] Auto-numbered footnote 5 again (duplicate). -""", -"""\ -<document source="test data"> - <paragraph> - Mixed manually-numbered, anonymous auto-numbered, - and labelled auto-numbered footnotes: - <paragraph> - <footnote_reference auto="1" id="id1" refid="four"> - 4 - should be 4, \n\ - <footnote_reference auto="1" id="id2" refid="id10"> - 2 - should be 2, - <footnote_reference id="id3" refid="id9"> - 1 - is 1, \n\ - <footnote_reference id="id4" refid="id11"> - 3 - is 3, - <footnote_reference auto="1" id="id5" refid="id12"> - 6 - should be 6, \n\ - <problematic id="id15" refid="id14"> - [#]_ - is one too many, - <footnote_reference auto="1" id="id7" refname="five"> - should be 5, and \n\ - <footnote_reference auto="1" id="id8" refname="eight"> - doesn't exist. - <footnote backrefs="id3" id="id9" name="1"> - <label> - 1 - <paragraph> - Manually-numbered footnote 1. - <footnote auto="1" backrefs="id2" id="id10" name="2"> - <label> - 2 - <paragraph> - Auto-numbered footnote 2. - <footnote auto="1" backrefs="id1" id="four" name="four"> - <label> - 4 - <paragraph> - Auto-numbered footnote 4. - <footnote backrefs="id4" id="id11" name="3"> - <label> - 3 - <paragraph> - Manually-numbered footnote 3 - <footnote auto="1" dupname="five" id="five"> - <label> - 5 - <paragraph> - Auto-numbered footnote 5. - <footnote auto="1" backrefs="id5" id="id12" name="6"> - <label> - 6 - <paragraph> - Auto-numbered footnote 6. - <footnote auto="1" dupname="five" id="id13"> - <label> - 7 - <system_message backrefs="id13" level="2" line="15" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "five". - <paragraph> - Auto-numbered footnote 5 again (duplicate). - <system_message backrefs="id15" id="id14" level="3" line="4" source="test data" type="ERROR"> - <paragraph> - Too many autonumbered footnote references: only 2 corresponding footnotes available. -"""], -["""\ -Referencing a footnote by symbol [*]_. - -.. [*] This is an auto-symbol footnote. -""", -"""\ -<document source="test data"> - <paragraph> - Referencing a footnote by symbol \n\ - <footnote_reference auto="*" id="id1" refid="id2"> - * - . - <footnote auto="*" backrefs="id1" id="id2"> - <label> - * - <paragraph> - This is an auto-symbol footnote. -"""], -["""\ -A sequence of symbol footnote references: -[*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_. - -.. [*] Auto-symbol footnote 1. -.. [*] Auto-symbol footnote 2. -.. [*] Auto-symbol footnote 3. -.. [*] Auto-symbol footnote 4. -.. [*] Auto-symbol footnote 5. -.. [*] Auto-symbol footnote 6. -.. [*] Auto-symbol footnote 7. -.. [*] Auto-symbol footnote 8. -.. [*] Auto-symbol footnote 9. -.. [*] Auto-symbol footnote 10. -.. [*] Auto-symbol footnote 11. -.. [*] Auto-symbol footnote 12. -""", -u"""\ -<document source="test data"> - <paragraph> - A sequence of symbol footnote references: - <footnote_reference auto="*" id="id1" refid="id13"> - * - \n\ - <footnote_reference auto="*" id="id2" refid="id14"> - \u2020 - \n\ - <footnote_reference auto="*" id="id3" refid="id15"> - \u2021 - \n\ - <footnote_reference auto="*" id="id4" refid="id16"> - \u00A7 - \n\ - <footnote_reference auto="*" id="id5" refid="id17"> - \u00B6 - \n\ - <footnote_reference auto="*" id="id6" refid="id18"> - # - \n\ - <footnote_reference auto="*" id="id7" refid="id19"> - \u2660 - \n\ - <footnote_reference auto="*" id="id8" refid="id20"> - \u2665 - \n\ - <footnote_reference auto="*" id="id9" refid="id21"> - \u2666 - \n\ - <footnote_reference auto="*" id="id10" refid="id22"> - \u2663 - \n\ - <footnote_reference auto="*" id="id11" refid="id23"> - ** - \n\ - <footnote_reference auto="*" id="id12" refid="id24"> - \u2020\u2020 - . - <footnote auto="*" backrefs="id1" id="id13"> - <label> - * - <paragraph> - Auto-symbol footnote 1. - <footnote auto="*" backrefs="id2" id="id14"> - <label> - \u2020 - <paragraph> - Auto-symbol footnote 2. - <footnote auto="*" backrefs="id3" id="id15"> - <label> - \u2021 - <paragraph> - Auto-symbol footnote 3. - <footnote auto="*" backrefs="id4" id="id16"> - <label> - \u00A7 - <paragraph> - Auto-symbol footnote 4. - <footnote auto="*" backrefs="id5" id="id17"> - <label> - \u00B6 - <paragraph> - Auto-symbol footnote 5. - <footnote auto="*" backrefs="id6" id="id18"> - <label> - # - <paragraph> - Auto-symbol footnote 6. - <footnote auto="*" backrefs="id7" id="id19"> - <label> - \u2660 - <paragraph> - Auto-symbol footnote 7. - <footnote auto="*" backrefs="id8" id="id20"> - <label> - \u2665 - <paragraph> - Auto-symbol footnote 8. - <footnote auto="*" backrefs="id9" id="id21"> - <label> - \u2666 - <paragraph> - Auto-symbol footnote 9. - <footnote auto="*" backrefs="id10" id="id22"> - <label> - \u2663 - <paragraph> - Auto-symbol footnote 10. - <footnote auto="*" backrefs="id11" id="id23"> - <label> - ** - <paragraph> - Auto-symbol footnote 11. - <footnote auto="*" backrefs="id12" id="id24"> - <label> - \u2020\u2020 - <paragraph> - Auto-symbol footnote 12. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_hyperlinks.py b/docutils/test/test_transforms/test_hyperlinks.py deleted file mode 100755 index 43e18d3f2..000000000 --- a/docutils/test/test_transforms/test_hyperlinks.py +++ /dev/null @@ -1,520 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for docutils.transforms.references.Hyperlinks. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import ChainedTargets, \ - AnonymousHyperlinks, IndirectHyperlinks, ExternalTargets, InternalTargets -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -# Exhaustive listing of hyperlink variations: every combination of -# target/reference, direct/indirect, internal/external, and named/anonymous, -# plus embedded URIs. -totest['exhaustive_hyperlinks'] = ((ChainedTargets, AnonymousHyperlinks, - IndirectHyperlinks, ExternalTargets, - InternalTargets,), [ -["""\ -direct_ external - -.. _direct: http://direct -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://direct"> - direct - external - <target id="direct" name="direct" refuri="http://direct"> -"""], -["""\ -indirect_ external - -.. _indirect: xtarget_ -.. _xtarget: http://indirect -""", -"""\ -<document source="test data"> - <paragraph> - <reference refuri="http://indirect"> - indirect - external - <target id="indirect" name="indirect" refuri="http://indirect"> - <target id="xtarget" name="xtarget" refuri="http://indirect"> -"""], -["""\ -.. _direct: - -direct_ internal -""", -"""\ -<document source="test data"> - <target id="direct" name="direct"> - <paragraph> - <reference refid="direct"> - direct - internal -"""], -["""\ -.. _ztarget: - -indirect_ internal - -.. _indirect2: ztarget_ -.. _indirect: indirect2_ -""", -"""\ -<document source="test data"> - <target id="ztarget" name="ztarget"> - <paragraph> - <reference refid="ztarget"> - indirect - internal - <target id="indirect2" name="indirect2" refid="ztarget"> - <target id="indirect" name="indirect" refid="ztarget"> -"""], -["""\ -Implicit --------- - -indirect_ internal - -.. _indirect: implicit_ -""", -"""\ -<document source="test data"> - <section id="implicit" name="implicit"> - <title> - Implicit - <paragraph> - <reference refid="implicit"> - indirect - internal - <target id="indirect" name="indirect" refid="implicit"> -"""], -["""\ -Implicit --------- - -`multiply-indirect`_ internal - -.. _multiply-indirect: indirect_ -.. _indirect: implicit_ -""", -"""\ -<document source="test data"> - <section id="implicit" name="implicit"> - <title> - Implicit - <paragraph> - <reference refid="implicit"> - multiply-indirect - internal - <target id="multiply-indirect" name="multiply-indirect" refid="implicit"> - <target id="indirect" name="indirect" refid="implicit"> -"""], -["""\ -circular_ indirect reference - -.. _circular: indirect_ -.. _indirect: circular_ -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id2" refid="id1"> - circular_ - indirect reference - <target id="circular" name="circular" refid="circular"> - <problematic id="id3" refid="id1"> - .. _indirect: circular_ - <system_message backrefs="id2 id3" id="id1" level="3" line="3" source="test data" type="ERROR"> - <paragraph> - Indirect hyperlink target "circular" (id="circular") refers to target "indirect", forming a circular reference. -"""], -["""\ -Implicit --------- - -Duplicate implicit targets. - -Implicit --------- - -indirect_ internal - -.. _indirect: implicit_ -""", -"""\ -<document source="test data"> - <section dupname="implicit" id="implicit"> - <title> - Implicit - <paragraph> - Duplicate implicit targets. - <section dupname="implicit" id="id1"> - <title> - Implicit - <system_message backrefs="id1" level="1" line="7" source="test data" type="INFO"> - <paragraph> - Duplicate implicit target name: "implicit". - <paragraph> - <problematic id="id3" refid="id2"> - indirect_ - internal - <target id="indirect" name="indirect" refname="implicit"> - <system_message backrefs="id3" id="id2" level="3" line="11" source="test data" type="ERROR"> - <paragraph> - Indirect hyperlink target "indirect" (id="indirect") refers to target "implicit", which does not exist. -"""], -["""\ -`direct external`__ - -__ http://direct -""", -"""\ -<document source="test data"> - <paragraph> - <reference anonymous="1" refuri="http://direct"> - direct external - <target anonymous="1" id="id1" refuri="http://direct"> -"""], -["""\ -`indirect external`__ - -__ xtarget_ -.. _xtarget: http://indirect -""", -"""\ -<document source="test data"> - <paragraph> - <reference anonymous="1" refuri="http://indirect"> - indirect external - <target anonymous="1" id="id1" refuri="http://indirect"> - <target id="xtarget" name="xtarget" refuri="http://indirect"> -"""], -["""\ -__ - -`direct internal`__ -""", -"""\ -<document source="test data"> - <target anonymous="1" id="id1"> - <paragraph> - <reference anonymous="1" refid="id1"> - direct internal -"""], -["""\ -.. _ztarget: - -`indirect internal`__ - -__ ztarget_ -""", -"""\ -<document source="test data"> - <target id="ztarget" name="ztarget"> - <paragraph> - <reference anonymous="1" refid="ztarget"> - indirect internal - <target anonymous="1" id="id1" refid="ztarget"> -"""], -["""\ -.. _ztarget: - -First - -.. _ztarget: - -Second - -`indirect internal`__ - -__ ztarget_ -""", -"""\ -<document source="test data"> - <target dupname="ztarget" id="ztarget"> - <paragraph> - First - <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "ztarget". - <target dupname="ztarget" id="id1"> - <paragraph> - Second - <paragraph> - <problematic id="id4" refid="id3"> - `indirect internal`__ - <target anonymous="1" id="id2" refname="ztarget"> - <system_message backrefs="id4" id="id3" level="3" line="11" source="test data" type="ERROR"> - <paragraph> - Indirect hyperlink target (id="id2") refers to target "ztarget", which does not exist. -"""], -["""\ -An `embedded uri <http://direct>`_. - -Another reference to the same `embedded URI`_. -""", -"""\ -<document source="test data"> - <paragraph> - An \n\ - <reference refuri="http://direct"> - embedded uri - <target id="embedded-uri" name="embedded uri" refuri="http://direct"> - . - <paragraph> - Another reference to the same \n\ - <reference refuri="http://direct"> - embedded URI - . -"""], -["""\ -An `anonymous embedded uri <http://direct>`__. -""", -"""\ -<document source="test data"> - <paragraph> - An \n\ - <reference refuri="http://direct"> - anonymous embedded uri - . -"""], -]) - -totest['hyperlinks'] = ((ChainedTargets, AnonymousHyperlinks, - IndirectHyperlinks, ExternalTargets, - InternalTargets,), [ -["""\ -.. _internal hyperlink: - -This paragraph referenced. - -By this `internal hyperlink`_ referemce. -""", -"""\ -<document source="test data"> - <target id="internal-hyperlink" name="internal hyperlink"> - <paragraph> - This paragraph referenced. - <paragraph> - By this \n\ - <reference refid="internal-hyperlink"> - internal hyperlink - referemce. -"""], -["""\ -.. _chained: -.. _internal hyperlink: - -This paragraph referenced. - -By this `internal hyperlink`_ referemce -as well as by this chained_ reference. - -The results of the transform are not visible at the XML level. -""", -"""\ -<document source="test data"> - <target id="chained" name="chained"> - <target id="internal-hyperlink" name="internal hyperlink"> - <paragraph> - This paragraph referenced. - <paragraph> - By this \n\ - <reference refid="internal-hyperlink"> - internal hyperlink - referemce - as well as by this \n\ - <reference refid="chained"> - chained - reference. - <paragraph> - The results of the transform are not visible at the XML level. -"""], -["""\ -.. _external hyperlink: http://uri - -`External hyperlink`_ reference. -""", -"""\ -<document source="test data"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <paragraph> - <reference refuri="http://uri"> - External hyperlink - reference. -"""], -["""\ -.. _external hyperlink: http://uri -.. _indirect target: `external hyperlink`_ -""", -"""\ -<document source="test data"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <target id="indirect-target" name="indirect target" refuri="http://uri"> - <system_message level="1" line="2" source="test data" type="INFO"> - <paragraph> - Indirect hyperlink target "indirect target" is not referenced. -"""], -["""\ -.. _chained: -.. _external hyperlink: http://uri - -`External hyperlink`_ reference -and a chained_ reference too. -""", -"""\ -<document source="test data"> - <target id="chained" name="chained" refuri="http://uri"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <paragraph> - <reference refuri="http://uri"> - External hyperlink - reference - and a \n\ - <reference refuri="http://uri"> - chained - reference too. -"""], -["""\ -.. _external hyperlink: http://uri -.. _indirect hyperlink: `external hyperlink`_ - -`Indirect hyperlink`_ reference. -""", -"""\ -<document source="test data"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <target id="indirect-hyperlink" name="indirect hyperlink" refuri="http://uri"> - <paragraph> - <reference refuri="http://uri"> - Indirect hyperlink - reference. -"""], -["""\ -.. _external hyperlink: http://uri -.. _chained: -.. _indirect hyperlink: `external hyperlink`_ - -Chained_ `indirect hyperlink`_ reference. -""", -"""\ -<document source="test data"> - <target id="external-hyperlink" name="external hyperlink" refuri="http://uri"> - <target id="chained" name="chained" refuri="http://uri"> - <target id="indirect-hyperlink" name="indirect hyperlink" refuri="http://uri"> - <paragraph> - <reference refuri="http://uri"> - Chained - \n\ - <reference refuri="http://uri"> - indirect hyperlink - reference. -"""], -["""\ -.. __: http://full -__ -__ http://simplified -.. _external: http://indirect.external -__ external_ -__ - -`Full syntax anonymous external hyperlink reference`__, -`chained anonymous external reference`__, -`simplified syntax anonymous external hyperlink reference`__, -`indirect anonymous hyperlink reference`__, -`internal anonymous hyperlink reference`__. -""", -"""\ -<document source="test data"> - <target anonymous="1" id="id1" refuri="http://full"> - <target anonymous="1" id="id2" refuri="http://simplified"> - <target anonymous="1" id="id3" refuri="http://simplified"> - <target id="external" name="external" refuri="http://indirect.external"> - <target anonymous="1" id="id4" refuri="http://indirect.external"> - <target anonymous="1" id="id5"> - <paragraph> - <reference anonymous="1" refuri="http://full"> - Full syntax anonymous external hyperlink reference - , - <reference anonymous="1" refuri="http://simplified"> - chained anonymous external reference - , - <reference anonymous="1" refuri="http://simplified"> - simplified syntax anonymous external hyperlink reference - , - <reference anonymous="1" refuri="http://indirect.external"> - indirect anonymous hyperlink reference - , - <reference anonymous="1" refid="id5"> - internal anonymous hyperlink reference - . -"""], -["""\ -Duplicate external target_'s (different URIs): - -.. _target: first - -.. _target: second -""", -"""\ -<document source="test data"> - <paragraph> - Duplicate external \n\ - <reference refname="target"> - target - 's (different URIs): - <target dupname="target" id="target" refuri="first"> - <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING"> - <paragraph> - Duplicate explicit target name: "target". - <target dupname="target" id="id1" refuri="second"> -"""], -["""\ -Several__ anonymous__ hyperlinks__, but not enough targets. - -__ http://example.org -""", -"""\ -<document source="test data"> - <paragraph> - <problematic id="id3" refid="id2"> - Several__ - \n\ - <problematic id="id4" refid="id2"> - anonymous__ - \n\ - <problematic id="id5" refid="id2"> - hyperlinks__ - , but not enough targets. - <target anonymous="1" id="id1" refuri="http://example.org"> - <system_message backrefs="id3 id4 id5" id="id2" level="3" source="test data" type="ERROR"> - <paragraph> - Anonymous hyperlink mismatch: 3 references but 1 targets. - See "backrefs" attribute for IDs. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_messages.py b/docutils/test/test_transforms/test_messages.py deleted file mode 100755 index 75325bc96..000000000 --- a/docutils/test/test_transforms/test_messages.py +++ /dev/null @@ -1,66 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for docutils.transforms.universal.Messages. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.universal import Messages -from docutils.transforms.references import Substitutions -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['system_message_sections'] = ((Substitutions, Messages), [ -["""\ -This |unknown substitution| will generate a system message, thanks to -the ``Substitutions`` transform. The ``Messages`` transform will -generate a "System Messages" section. - -(A second copy of the system message is tacked on to the end of the -document by the test framework.) -""", -"""\ -<document source="test data"> - <paragraph> - This \n\ - <problematic id="id2" refid="id1"> - |unknown substitution| - will generate a system message, thanks to - the \n\ - <literal> - Substitutions - transform. The \n\ - <literal> - Messages - transform will - generate a "System Messages" section. - <paragraph> - (A second copy of the system message is tacked on to the end of the - document by the test framework.) - <section class="system-messages"> - <title> - Docutils System Messages - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Undefined substitution referenced: "unknown substitution". -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_peps.py b/docutils/test/test_transforms/test_peps.py deleted file mode 100644 index 28fa68af2..000000000 --- a/docutils/test/test_transforms/test_peps.py +++ /dev/null @@ -1,68 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for docutils.transforms.peps. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.peps import TargetNotes -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['target_notes'] = ((TargetNotes,), [ -["""\ -No references or targets exist, therefore -no "References" section should be generated. -""", -"""\ -<document source="test data"> - <paragraph> - No references or targets exist, therefore - no "References" section should be generated. -"""], -["""\ -A target exists, here's the reference_. -A "References" section should be generated. - -.. _reference: http://www.example.org -""", -"""\ -<document source="test data"> - <paragraph> - A target exists, here's the \n\ - <reference refname="reference"> - reference - \n\ - <footnote_reference auto="1" id="id3" refname="target_note: id2"> - . - A "References" section should be generated. - <target id="reference" name="reference" refuri="http://www.example.org"> - <section id="id1"> - <title> - References - <footnote auto="1" id="id2" name="target_note: id2"> - <paragraph> - <reference refuri="http://www.example.org"> - http://www.example.org -"""], -]) - - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_sectnum.py b/docutils/test/test_transforms/test_sectnum.py deleted file mode 100644 index 543deac16..000000000 --- a/docutils/test/test_transforms/test_sectnum.py +++ /dev/null @@ -1,226 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger, Dmitry Jemerov -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for `docutils.transforms.parts.SectNum` (via -`docutils.transforms.universal.LastReaderPending`). -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import Substitutions -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['section_numbers'] = ((Substitutions,), [ -["""\ -.. sectnum:: - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -u"""\ -<document source="test data"> - <section id="title-1" name="title 1"> - <title auto="1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title auto="1"> - <generated class="sectnum"> - 1.1\u00a0\u00a0\u00a0 - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title auto="1"> - <generated class="sectnum"> - 1.1.1\u00a0\u00a0\u00a0 - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title auto="1"> - <generated class="sectnum"> - 1.2\u00a0\u00a0\u00a0 - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -.. sectnum:: - -**Bold Title** -============== -Paragraph 1. -""", -u"""\ -<document source="test data"> - <section id="bold-title" name="bold title"> - <title auto="1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - <strong> - Bold Title - <paragraph> - Paragraph 1. -"""], -["""\ -.. sectnum:: :depth: 2 - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -u"""\ -<document source="test data"> - <section id="title-1" name="title 1"> - <title auto="1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title auto="1"> - <generated class="sectnum"> - 1.1\u00a0\u00a0\u00a0 - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title auto="1"> - <generated class="sectnum"> - 1.2\u00a0\u00a0\u00a0 - Title 4 - <paragraph> - Paragraph 4. -"""], -["""\ -.. contents:: -.. sectnum:: :depth: 2 - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. - -Title 3 -``````` -Paragraph 3. - -Title 4 -------- -Paragraph 4. -""", -u"""\ -<document source="test data"> - <topic class="contents" id="contents" name="contents"> - <title> - Contents - <bullet_list class="auto-toc"> - <list_item> - <paragraph> - <reference id="id1" refid="title-1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - Title 1 - <bullet_list class="auto-toc"> - <list_item> - <paragraph> - <reference id="id2" refid="title-2"> - <generated class="sectnum"> - 1.1\u00a0\u00a0\u00a0 - Title 2 - <bullet_list> - <list_item> - <paragraph> - <reference id="id3" refid="title-3"> - Title 3 - <list_item> - <paragraph> - <reference id="id4" refid="title-4"> - <generated class="sectnum"> - 1.2\u00a0\u00a0\u00a0 - Title 4 - <section id="title-1" name="title 1"> - <title auto="1" refid="id1"> - <generated class="sectnum"> - 1\u00a0\u00a0\u00a0 - Title 1 - <paragraph> - Paragraph 1. - <section id="title-2" name="title 2"> - <title auto="1" refid="id2"> - <generated class="sectnum"> - 1.1\u00a0\u00a0\u00a0 - Title 2 - <paragraph> - Paragraph 2. - <section id="title-3" name="title 3"> - <title refid="id3"> - Title 3 - <paragraph> - Paragraph 3. - <section id="title-4" name="title 4"> - <title auto="1" refid="id4"> - <generated class="sectnum"> - 1.2\u00a0\u00a0\u00a0 - Title 4 - <paragraph> - Paragraph 4. -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_substitutions.py b/docutils/test/test_transforms/test_substitutions.py deleted file mode 100755 index 503dfba40..000000000 --- a/docutils/test/test_transforms/test_substitutions.py +++ /dev/null @@ -1,151 +0,0 @@ -#! /usr/bin/env python - -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for docutils.transforms.references.Substitutions. -""" - -from __init__ import DocutilsTestSupport -from docutils.transforms.references import Substitutions -from docutils.parsers.rst import Parser - - -def suite(): - parser = Parser() - s = DocutilsTestSupport.TransformTestSuite(parser) - s.generateTests(totest) - return s - -totest = {} - -totest['substitutions'] = ((Substitutions,), [ -["""\ -The |biohazard| symbol is deservedly scary-looking. - -.. |biohazard| image:: biohazard.png -""", -"""\ -<document source="test data"> - <paragraph> - The \n\ - <image alt="biohazard" uri="biohazard.png"> - symbol is deservedly scary-looking. - <substitution_definition name="biohazard"> - <image alt="biohazard" uri="biohazard.png"> -"""], -["""\ -Here's an |unknown| substitution. -""", -"""\ -<document source="test data"> - <paragraph> - Here's an \n\ - <problematic id="id2" refid="id1"> - |unknown| - substitution. - <system_message backrefs="id2" id="id1" level="3" line="1" source="test data" type="ERROR"> - <paragraph> - Undefined substitution referenced: "unknown". -"""], -[u"""\ -Substitutions support case differences: - -.. |eacute| replace:: \u00E9 -.. |Eacute| replace:: \u00C9 - -|Eacute|\\t\\ |eacute|, and even |EACUTE|. -""", -u"""\ -<document source="test data"> - <paragraph> - Substitutions support case differences: - <substitution_definition name="eacute"> - \u00E9 - <substitution_definition name="Eacute"> - \u00C9 - <paragraph> - \u00C9 - t - \u00E9 - , and even \n\ - \u00C9 - . -"""], -]) - -totest['unicode'] = ((Substitutions,), [ -["""\ -Insert an em-dash (|mdash|), a copyright symbol (|copy|), a non-breaking -space (|nbsp|), a backwards-not-equals (|bne|), and a captial omega (|Omega|). - -.. |mdash| unicode:: 0x02014 -.. |copy| unicode:: \\u00A9 -.. |nbsp| unicode::   -.. |bne| unicode:: U0003D U020E5 -.. |Omega| unicode:: U+003A9 -""", -u"""\ -<document source="test data"> - <paragraph> - Insert an em-dash ( - \u2014 - ), a copyright symbol ( - \u00a9 - ), a non-breaking - space ( - \u00a0 - ), a backwards-not-equals ( - = - \u20e5 - ), and a captial omega ( - \u03a9 - ). - <substitution_definition name="mdash"> - \u2014 - <substitution_definition name="copy"> - \u00a9 - <substitution_definition name="nbsp"> - \u00a0 - <substitution_definition name="bne"> - = - \u20e5 - <substitution_definition name="Omega"> - \u03a9 -"""], -[""" -Testing comments and extra text. - -Copyright |copy| 2003, |BogusMegaCorp (TM)|. - -.. |copy| unicode:: 0xA9 .. copyright sign -.. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122 - .. with trademark sign -""", -u"""\ -<document source="test data"> - <paragraph> - Testing comments and extra text. - <paragraph> - Copyright \n\ - \u00a9 - 2003, \n\ - BogusMegaCorp - \u2122 - . - <substitution_definition name="copy"> - \u00a9 - <substitution_definition name="BogusMegaCorp (TM)"> - BogusMegaCorp - \u2122 -"""], -]) - - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') diff --git a/docutils/test/test_utils.py b/docutils/test/test_utils.py deleted file mode 100755 index dc4297113..000000000 --- a/docutils/test/test_utils.py +++ /dev/null @@ -1,297 +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 -import StringIO -import sys -from DocutilsTestSupport import utils, nodes - - -class ReporterTests(unittest.TestCase): - - stream = StringIO.StringIO() - reporter = utils.Reporter('test data', 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" source="test data" type="DEBUG"> - <paragraph> - debug output -""") - self.assertEquals(self.stream.getvalue(), - 'test data:: (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" source="test data" 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" source="test data" type="WARNING"> - <paragraph> - a warning -""") - self.assertEquals(self.stream.getvalue(), - 'test data:: (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" source="test data" type="ERROR"> - <paragraph> - an error -""") - self.assertEquals(self.stream.getvalue(), - 'test data:: (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(), 'test data:: (SEVERE/4) ' - 'a severe error, raises an exception\n') - - -class QuietReporterTests(unittest.TestCase): - - stream = StringIO.StringIO() - reporter = utils.Reporter('test data', 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" source="test data" 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" source="test data" 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" source="test data" 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" source="test data" 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" source="test data" 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('test data', 2, 4, self.stream, 1) - self.reporter.set_conditions('lemon', 1, 3, self.stream, 0) - - def test_getset(self): - self.reporter.set_conditions('test', 5, 5, None, 0) - self.assertEquals(self.reporter.get_conditions('other').astuple(), - (1, 2, 4, self.stream)) - self.assertEquals(self.reporter.get_conditions('test').astuple(), - (0, 5, 5, sys.stderr)) - self.assertEquals(self.reporter.get_conditions('test.dummy').astuple(), - (0, 5, 5, sys.stderr)) - self.reporter.set_conditions('test.dummy.spam', 1, 2, self.stream, 1) - self.assertEquals( - self.reporter.get_conditions('test.dummy.spam').astuple(), - (1, 1, 2, self.stream)) - self.assertEquals(self.reporter.get_conditions('test.dummy').astuple(), - (0, 5, 5, sys.stderr)) - self.assertEquals( - self.reporter.get_conditions('test.dummy.spam.eggs').astuple(), - (1, 1, 2, self.stream)) - self.reporter.unset_conditions('test.dummy.spam') - self.assertEquals( - self.reporter.get_conditions('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(), - 'test data:: (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(), - 'test data:: (INFO/1) some info [lemon.curry]\n') - - def test_warning(self): - sw = self.reporter.warning('a warning') - self.assertEquals(self.stream.getvalue(), - 'test data:: (WARNING/2) a warning\n') - sw = self.reporter.warning('a warning', category='lemon.curry') - self.assertEquals(self.stream.getvalue(), """\ -test data:: (WARNING/2) a warning -test data:: (WARNING/2) a warning [lemon.curry] -""") - - def test_error(self): - sw = self.reporter.error('an error') - self.assertEquals(self.stream.getvalue(), - 'test data:: (ERROR/3) an error\n') - self.assertRaises(utils.SystemMessage, self.reporter.error, - 'an error', category='lemon.curry') - self.assertEquals(self.stream.getvalue(), """\ -test data:: (ERROR/3) an error -test data:: (ERROR/3) an error [lemon.curry] -""") - - def test_severe(self): - self.assertRaises(utils.SystemMessage, self.reporter.severe, - 'a severe error') - self.assertEquals(self.stream.getvalue(), - 'test data:: (SEVERE/4) a severe error\n') - self.assertRaises(utils.SystemMessage, self.reporter.severe, - 'a severe error', category='lemon.curry') - self.assertEquals(self.stream.getvalue(), """\ -test data:: (SEVERE/4) a severe error -test data:: (SEVERE/4) a severe error [lemon.curry] -""") - - -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 ExtensionOptionTests(unittest.TestCase): - - optionspec = {'a': int, 'bbb': float, 'cdef': (lambda x: x), - 'empty': (lambda x: x)} - - def test_assemble_option_dict(self): - input = utils.extract_name_value('a=1 bbb=2.0 cdef=hol%s' % chr(224)) - self.assertEquals( - utils.assemble_option_dict(input, self.optionspec), - {'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_option_dict, - input, self.optionspec) - input = utils.extract_name_value('a=1 bbb=two cdef=hol%s' % chr(224)) - self.assertRaises(ValueError, utils.assemble_option_dict, - input, self.optionspec) - - def test_extract_extension_options(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_options(field_list, self.optionspec), - {'a': 1, 'bbb': 2.0, 'cdef': ('hol%s' % chr(224)), - 'empty': None}) - self.assertRaises(KeyError, utils.extract_extension_options, - field_list, {}) - field_list += nodes.field( - '', nodes.field_name('', 'cdef'), - nodes.field_body('', nodes.paragraph('', 'one'), - nodes.paragraph('', 'two'))) - self.assertRaises(utils.BadOptionDataError, - utils.extract_extension_options, - field_list, self.optionspec) - field_list[-1] = nodes.field( - '', nodes.field_name('', 'cdef bad'), - nodes.field_body('', nodes.paragraph('', 'no arguments'))) - self.assertRaises(utils.BadOptionError, - utils.extract_extension_options, - field_list, self.optionspec) - field_list[-1] = nodes.field( - '', nodes.field_name('', 'cdef'), - nodes.field_body('', nodes.paragraph('', 'duplicate'))) - self.assertRaises(utils.DuplicateOptionError, - utils.extract_extension_options, - field_list, self.optionspec) - field_list[-2] = nodes.field( - '', nodes.field_name('', 'unkown'), - nodes.field_body('', nodes.paragraph('', 'unknown'))) - self.assertRaises(KeyError, utils.extract_extension_options, - field_list, self.optionspec) - - -if __name__ == '__main__': - unittest.main() diff --git a/docutils/test/test_viewlist.py b/docutils/test/test_viewlist.py deleted file mode 100644 index 3ddf1fcf1..000000000 --- a/docutils/test/test_viewlist.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. - -""" -Test module for the ViewList class from statemachine.py. -""" - -import unittest -import sys -import re -from DocutilsTestSupport import statemachine - - -class ViewListTests(unittest.TestCase): - - a_list = list('abcdefg') - b_list = list('AEIOU') - c_list = list('XYZ') - - def setUp(self): - self.a = statemachine.ViewList(self.a_list, 'a') - self.b = statemachine.ViewList(self.b_list, 'b') - self.c = statemachine.ViewList(self.c_list, 'c') - - def test_lists(self): - self.assertEqual(self.a, self.a_list) - self.assertEqual(str(self.a), str(self.a_list)) - self.assertEqual(self.b, self.b_list) - self.assertEqual(self.c, self.c_list) - self.assertEqual(self.a.items, - zip('a' * len(self.a_list), range(len(self.a_list)))) - - def test_get_slice(self): - a = self.a[1:-1] - a_list = self.a_list[1:-1] - self.assertEqual(a, a_list) - self.assertEqual(a.items, - zip('a' * len(a_list), range(1, len(a_list) + 1))) - self.assertEqual(a.parent, self.a) - - def test_set_slice(self): - a = statemachine.ViewList(self.a[:]) - s = a[2:-2] - s[2:2] = self.b - s_list = self.a_list[2:-2] - s_list[2:2] = self.b_list - self.assertEqual(s, s_list) - self.assertEqual(s, a[2:-2]) - self.assertEqual(s.items, a[2:-2].items) - - def test_del_slice(self): - a = statemachine.ViewList(self.a[:]) - s = a[2:] - s_list = self.a_list[2:] - del s[3:5] - del s_list[3:5] - self.assertEqual(s, s_list) - self.assertEqual(s, a[2:]) - self.assertEqual(s.items, a[2:].items) - - def test_insert(self): - a_list = self.a_list[:] - a_list.insert(2, 'Q') - a_list[4:4] = self.b_list - a = self.a[:] - self.assert_(isinstance(a, statemachine.ViewList)) - a.insert(2, 'Q', 'runtime') - a.insert(4, self.b) - self.assertEqual(a, a_list) - self.assertEqual(a.info(2), ('runtime', 0)) - self.assertEqual(a.info(5), ('b', 1)) - - def test_append(self): - a_list = self.a_list[:] - a_list.append('Q') - a_list.extend(self.b_list) - a = statemachine.ViewList(self.a) - a.append('Q', 'runtime') - a.append(self.b) - self.assertEqual(a, a_list) - self.assertEqual(a.info(len(self.a)), ('runtime', 0)) - self.assertEqual(a.info(-2), ('b', len(self.b) - 2)) - - def test_extend(self): - a_list = self.a_list[:] - a_list.extend(self.b_list) - a = statemachine.ViewList(self.a) - a.extend(self.b) - self.assertEqual(a, a_list) - self.assertEqual(a.info(len(self.a) + 1), ('b', 1)) - - def test_view(self): - a = statemachine.ViewList(self.a[:]) - a.insert(4, self.b) - s = a[2:-2] - s.insert(5, self.c) - self.assertEqual(s, a[2:-2]) - self.assertEqual(s.items, a[2:-2].items) - s.pop() - self.assertEqual(s, a[2:-2]) - self.assertEqual(s.items, a[2:-2].items) - s.remove('X') - self.assertEqual(s, a[2:-2]) - self.assertEqual(s.items, a[2:-2].items) - - def test_trim(self): - a = statemachine.ViewList(self.a[:]) - s = a[1:-1] - s.trim_start(1) - self.assertEquals(a, self.a) - self.assertEquals(s, a[2:-1]) - s.trim_end(1) - self.assertEquals(a, self.a) - self.assertEquals(s, a[2:-2]) - - -# print -# print a -# print s -# print a.items -# print s.items - - -class StringList(unittest.TestCase): - - text = """\ -This is some -example text. - - Here is some - indented text. - -Unindented text. -""" - - indented_string = """\ - a - literal - block""" - - - def setUp(self): - self.a_list = self.text.splitlines(1) - self.a = statemachine.StringList(self.a_list, 'a') - - def test_strip_indent(self): - s = self.a[3:5] - s.strip_indent(4) - self.assertEqual(s, [line.lstrip() for line in self.a_list[3:5]]) - - def test_get_indented(self): - self.assertEquals(self.a.get_indented(), - ([], 0, 0)) - block = statemachine.StringList( - statemachine.string2lines(self.indented_string)) - self.assertEquals(block.get_indented(), - ([s[6:] for s in block], 6, 1)) - - -if __name__ == '__main__': - unittest.main() diff --git a/docutils/test/test_writers/__init__.py b/docutils/test/test_writers/__init__.py deleted file mode 100644 index 2fe79c55c..000000000 --- a/docutils/test/test_writers/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import os.path -import sys - -sys.path.insert(0, os.path.abspath(os.curdir)) -prev = '' -while sys.path[0] != prev: - try: - import DocutilsTestSupport - break - except ImportError: - prev = sys.path[0] - sys.path[0] = os.path.dirname(prev) -sys.path.pop(0) diff --git a/docutils/test/test_writers/test_latex2e.py b/docutils/test/test_writers/test_latex2e.py deleted file mode 100644 index 75a013fe6..000000000 --- a/docutils/test/test_writers/test_latex2e.py +++ /dev/null @@ -1,255 +0,0 @@ -#! /usr/bin/env python - -# Author: engelbert gruber -# Contact: grubert@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -Tests for latex2e writer. -""" - -from __init__ import DocutilsTestSupport - -def suite(): - s = DocutilsTestSupport.LatexPublishTestSuite() - s.generateTests(totest) - return s - - -latex_head = """\ -\\documentclass[10pt,english]{article} -\\usepackage{babel} -\\usepackage{shortvrb} -\\usepackage[latin1]{inputenc} -\\usepackage{tabularx} -\\usepackage{longtable} -\\setlength{\\extrarowheight}{2pt} -\\usepackage{amsmath} -\\usepackage{graphicx} -\\usepackage{color} -\\usepackage{multirow} -\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref} -\\usepackage[a4paper,margin=2cm,nohead]{geometry} -%% generator Docutils: http://docutils.sourceforge.net/ -\\newlength{\\admonitionwidth} -\\setlength{\\admonitionwidth}{0.9\\textwidth} -\\newlength{\\docinfowidth} -\\setlength{\\docinfowidth}{0.9\\textwidth} -\\newcommand{\\optionlistlabel}[1]{\\bf #1 \\hfill} -\\newenvironment{optionlist}[1] -{\\begin{list}{} - {\\setlength{\\labelwidth}{#1} - \\setlength{\\rightmargin}{1cm} - \\setlength{\\leftmargin}{\\rightmargin} - \\addtolength{\\leftmargin}{\\labelwidth} - \\addtolength{\\leftmargin}{\\labelsep} - \\renewcommand{\\makelabel}{\\optionlistlabel}} -}{\\end{list}} -% begin: floats for footnotes tweaking. -\\setlength{\\floatsep}{0.5em} -\\setlength{\\textfloatsep}{\\fill} -\\addtolength{\\textfloatsep}{3em} -\\renewcommand{\\textfraction}{0.5} -\\renewcommand{\\topfraction}{0.5} -\\renewcommand{\\bottomfraction}{0.5} -\\setcounter{totalnumber}{50} -\\setcounter{topnumber}{50} -\\setcounter{bottomnumber}{50} -% end floats for footnotes -% some commands, that could be overwritten in the style file. -\\newcommand{\\rubric}[1]{\\subsection*{~\\hfill {\\it #1} \\hfill ~}} -% end of "some commands" -\\input{style.tex} -""" - -totest = {} - -totest['table_of_contents'] = [ -# input -["""\ -.. contents:: Table of Contents - -Title 1 -======= -Paragraph 1. - -Title 2 -------- -Paragraph 2. -""", -# expected output -latex_head + """\ -\\title{Title 1} -\\author{} -\\date{} -\\hypersetup{\npdftitle={Title 1} -} -\\raggedbottom -\\begin{document} -\\maketitle - -\\hypertarget{table-of-contents}{}\\subsection*{~\\hfill Table of Contents\\hfill ~} -\\pdfbookmark[0]{Table of Contents}{table-of-contents} -\\begin{list}{}{} -\\item \\href{#title-2}{Title 2} - -\\end{list} - - -Paragraph 1. - - -%___________________________________________________________________________ - -\\hypertarget{title-2}{} -\\section*{Title 2} -\\pdfbookmark[0]{Title 2}{title-2} - -Paragraph 2. - -\\end{document} -"""], - -] - - -totest['enumerated_lists'] = [ -# input -["""\ -1. Item 1. -2. Second to the previous item this one will explain - - a) nothing. - b) or some other. - -3. Third is - - (I) having pre and postfixes - (II) in roman numerals. -""", -# expected output -latex_head + """\ -\\title{} -\\author{} -\\date{} -\\raggedbottom -\\begin{document} -\\maketitle - -\\newcounter{listcnt1} -\\begin{list}{\\arabic{listcnt1}.} -{ -\\usecounter{listcnt1} -\\setlength{\\rightmargin}{\\leftmargin} -} -\\item -Item 1. - -\\item -Second to the previous item this one will explain - -\\end{list} -\\begin{quote} -\\newcounter{listcnt2} -\\begin{list}{\\alph{listcnt2})} -{ -\\usecounter{listcnt2} -\\setlength{\\rightmargin}{\\leftmargin} -} -\\item -nothing. - -\\item -or some other. - -\\end{list} -\\end{quote} -\\newcounter{listcnt3} -\\begin{list}{\\arabic{listcnt3}.} -{ -\\usecounter{listcnt3} -\\addtocounter{listcnt3}{2} -\\setlength{\\rightmargin}{\\leftmargin} -} -\\item -Third is - -\\end{list} -\\begin{quote} -\\newcounter{listcnt4} -\\begin{list}{(\\Roman{listcnt4})} -{ -\\usecounter{listcnt4} -\\setlength{\\rightmargin}{\\leftmargin} -} -\\item -having pre and postfixes - -\\item -in roman numerals. - -\\end{list} -\\end{quote} - -\\end{document} -"""], -] - -# BUG: need to test for quote replacing if language is de (ngerman). - -totest['quote_mangling'] = [ -# input -["""\ -Depending on language quotes are converted for latex. -Expecting "en" here. - -Inside literal blocks quotes should be left untouched -(use only two quotes in test code makes life easier for -the python interpreter running the test):: - - "" - This is left "untouched" also *this*. - "" - -.. parsed-literal:: - - should get "quotes" and *italics*. - - -Inline ``literal "quotes"`` should be kept. -""", -latex_head + """\ -\\title{} -\\author{} -\\date{} -\\raggedbottom -\\begin{document} -\\maketitle - - -Depending on language quotes are converted for latex. -Expecting ``en'' here. - -Inside literal blocks quotes should be left untouched -(use only two quotes in test code makes life easier for -the python interpreter running the test): -\\begin{ttfamily}\\begin{flushleft} -\\mbox{""}\\\\ -\\mbox{This~is~left~"untouched"~also~*this*.}\\\\ -\\mbox{""} -\\end{flushleft}\\end{ttfamily} -\\begin{ttfamily}\\begin{flushleft} -\\mbox{should~get~"quotes"~and~\\emph{italics}.} -\\end{flushleft}\\end{ttfamily} - -Inline \\texttt{literal "quotes"} should be kept. - -\\end{document} -"""], -] - -if __name__ == '__main__': - import unittest - unittest.main(defaultTest='suite') |
