summaryrefslogtreecommitdiff
path: root/sandbox/dkuhlman/docutils/test
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/dkuhlman/docutils/test')
-rw-r--r--sandbox/dkuhlman/docutils/test/DocutilsTestSupport.py698
-rw-r--r--sandbox/dkuhlman/docutils/test/README.test_python_latex36
-rw-r--r--sandbox/dkuhlman/docutils/test/test_writers/test_python_latex.py490
3 files changed, 0 insertions, 1224 deletions
diff --git a/sandbox/dkuhlman/docutils/test/DocutilsTestSupport.py b/sandbox/dkuhlman/docutils/test/DocutilsTestSupport.py
deleted file mode 100644
index e40300984..000000000
--- a/sandbox/dkuhlman/docutils/test/DocutilsTestSupport.py
+++ /dev/null
@@ -1,698 +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'
- - 'PythonLatexPublishTestSuite'
- - 'PythonLatexPublishTestCase'
- - `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 StringList, string2lines
-
-try:
- from docutils.readers.python import moduleparser
-except:
- moduleparser = None
-
-try:
- import mypdb as pdb
-except:
- import pdb
-
-
-# Hack to make repr(StringList) look like repr(list):
-StringList.__repr__ = StringList.__str__
-
-
-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(StringList(string2lines(self.input), 'test data'))
- 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(StringList(string2lines(self.input),
- 'test data'))
- 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)
-
-
-class PythonLatexPublishTestCase(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='python_latex',
- settings_spec=self)
- self.compare_output(self.input, output, self.expected)
-
- 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')
- # Remove "generated on" lines.
- output = self.remove_lines(output, ('generated on --',))
- expected = self.remove_lines(expected, ('generated on --',))
- 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 remove_lines(self, inStr, targetList):
- inLines = inStr.splitlines()
- outLines = []
- for line in inLines:
- remove = False
- for target in targetList:
- if line.find(target) > -1:
- remove = True
- break
- if not remove:
- outLines.append(line)
- outStr = '\n'.join(outLines)
- return outStr
-
-class PythonLatexPublishTestSuite(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(
- PythonLatexPublishTestCase, 'test_publish',
- input=case[0], expected=case[1],
- id='%s[%r][%s]' % (dictname, name, casenum),
- run_in_debugger=run_in_debugger)
-
-
-def exception_data(code):
- """
- Execute `code` and return the resulting exception, the exception arguments,
- and the formatted exception string.
- """
- try:
- exec(code)
- except Exception, detail:
- return (detail, detail.args,
- '%s: %s' % (detail.__class__.__name__, detail))
diff --git a/sandbox/dkuhlman/docutils/test/README.test_python_latex b/sandbox/dkuhlman/docutils/test/README.test_python_latex
deleted file mode 100644
index a8321744e..000000000
--- a/sandbox/dkuhlman/docutils/test/README.test_python_latex
+++ /dev/null
@@ -1,36 +0,0 @@
-
-=============================================
-Notes on Unit Test Additions for Python LaTeX
-=============================================
-
-
-DocutilsTestSupport.py
-======================
-
-Added two classes (PythonLatexPublishTestCase and
-PythonLatexPublishTestSuite) that drive the tests. These classes
-were modelled on classes LatexPublishTestCase and
-LatexPublishTestSuite respectively.
-
-Note that class PythonLatexPublishTestCase overrides method
-compare_output and adds method remove_lines. These methods remove
-the "generated on" lines from both input and output because the
-date will always differ.
-
-See file DocutilsTestSupport.patch
-
-
-test_writers/test_python_latex.py
-=================================
-
-Contains the tests.
-
-
-test_writers/Data/*
-===================
-
-Contains reST source documents (*.txt) and generated LaTeX
-documents (*.tex) that were used in the input and output strings
-in test_python_latex.py.
-
-
diff --git a/sandbox/dkuhlman/docutils/test/test_writers/test_python_latex.py b/sandbox/dkuhlman/docutils/test/test_writers/test_python_latex.py
deleted file mode 100644
index 7aa5528ce..000000000
--- a/sandbox/dkuhlman/docutils/test/test_writers/test_python_latex.py
+++ /dev/null
@@ -1,490 +0,0 @@
-#! /usr/bin/env python
-
-# Author: Dave Kuhlman
-# Contact: dkuhlman@rexx.com
-# Revision: $Revision$
-# Date: $Date$
-# Copyright: This module has been placed in the public domain.
-
-"""
-Tests for python_latex writer.
-"""
-
-from __init__ import DocutilsTestSupport
-
-def suite():
- s = DocutilsTestSupport.PythonLatexPublishTestSuite()
- s.generateTests(totest)
- return s
-
-
-rest_head = """\
-
-==========================
-Unit Test for Python LaTeX
-==========================
-
-
-:author: Dave Kuhlman
-:address: dkuhlman@rexx.com \\\\
- http://www.rexx.com/~dkuhlman
-
-:revision: 1.0a
-:date: Aug. 4, 2003
-
-:copyright: Copyright (c) 2003 Dave Kuhlman.
- [an Open Source copyright]
-
-:abstract: This document contains input for unit tests for the
- Python LaTeX writer for Docutils.
-
-.. sectnum:: :depth: 2
-
-.. contents::
-
-
-"""
-
-latex_head = r"""\documentclass{howto}
-
-% generator -- Docutils: http://docutils.sourceforge.net/
-% writer -- documenting_python
-% generated on -- Wed Aug 13 16:08:04 2003
-
-\usepackage{html}
-\title{Unit Test for Python LaTeX}
-\release{1.0a}
-\date{Aug. 4, 2003}
-\author{Dave Kuhlman}
-\authoraddress{dkuhlman@rexx.com \
-http://www.rexx.com/\~{}dkuhlman}
-\begin{document}
-\maketitle
-\ifhtml
-\chapter*{Front Matter\label{front}}
-\fi
-
-Copyright (c) 2003 Dave Kuhlman.
-[an Open Source copyright]
-\begin{abstract}
-\noindent
-
-This document contains input for unit tests for the
-Python LaTeX writer for Docutils.
-\end{abstract}
-\tableofcontents
-
-"""
-
-totest = {}
-
-totest['section_headers'] = [
-# input
-[rest_head + r"""
-Section #1
-==========
-
-Content for section #1.
-
-Subsection #1-1
----------------
-
-Content for sub-section #1-1.
-
-Subsection #1-2
----------------
-
-Content for sub-section #1-2.
-
-Section #2
-==========
-
-Content for section #2.
-
-""",
-
-# expected output
-latex_head + r"""
-%___________________________________________________________________________
-
-\section{1   Section {\#}1\label{section-1}}
-
-Content for section {\#}1.
-
-
-%___________________________________________________________________________
-
-\subsection{1.1   Subsection {\#}1-1\label{subsection-1-1}}
-
-Content for sub-section {\#}1-1.
-
-
-%___________________________________________________________________________
-
-\subsection{1.2   Subsection {\#}1-2\label{subsection-1-2}}
-
-Content for sub-section {\#}1-2.
-
-
-%___________________________________________________________________________
-
-\section{2   Section {\#}2\label{section-2}}
-
-Content for section {\#}2.
-
-\end{document}
-"""],
-]
-
-# ==============================================================
-
-totest['enumerated_lists'] = [
-# input
-[rest_head + r"""
-Enumerated List Test Section
-============================
-
-Here is an enumerated list:
-
-1. This is an item.
-
-2. This is an item.
-
-3. This is an item.
-
-""",
-
-# expected output
-latex_head + r"""
-%___________________________________________________________________________
-
-\section{1   Enumerated List Test Section\label{enumerated-list-test-section}}
-
-Here is an enumerated list:
-\begin{enumerate}
-\item
-This is an item.
-
-\item
-This is an item.
-
-\item
-This is an item.
-
-\end{enumerate}
-
-\end{document}
-"""],
-]
-
-
-# ==============================================================
-
-totest['itemized_lists'] = [
-# input
-[rest_head + r"""
-Itemized List Test Section
-==========================
-
-Here is an itemized list:
-
-- This is an item.
-
-- This is an item.
-
-- This is an item.
-
-""",
-
-# expected output
-latex_head + r"""
-%___________________________________________________________________________
-
-\section{1   Itemized List Test Section\label{itemized-list-test-section}}
-
-Here is an itemized list:
-\begin{itemize}
-\item
-This is an item.
-
-\item
-This is an item.
-
-\item
-This is an item.
-
-\end{itemize}
-
-\end{document}
-"""],
-]
-
-# ==============================================================
-
-totest['links'] = [
-# input
-[rest_head + r"""
-Section #1
-==========
-
-Content for section #1.
-
-Subsection #1-1
----------------
-
-Content for sub-section #1-1.
-
-Subsection #1-2
----------------
-
-Content for sub-section #1-2.
-
-Section #2
-==========
-
-Content for section #2.
-
-Links Test Section
-==================
-
-Here is a link to the section which is the target of this
-internal link `Subsection #1-1`_.
-
-""",
-
-# expected output
-latex_head + r"""
-%___________________________________________________________________________
-
-\section{1   Section {\#}1\label{section-1}}
-
-Content for section {\#}1.
-
-
-%___________________________________________________________________________
-
-\subsection{1.1   Subsection {\#}1-1\label{subsection-1-1}}
-
-Content for sub-section {\#}1-1.
-
-
-%___________________________________________________________________________
-
-\subsection{1.2   Subsection {\#}1-2\label{subsection-1-2}}
-
-Content for sub-section {\#}1-2.
-
-
-%___________________________________________________________________________
-
-\section{2   Section {\#}2\label{section-2}}
-
-Content for section {\#}2.
-
-
-%___________________________________________________________________________
-
-\section{3   Links Test Section\label{links-test-section}}
-
-Here is a link to the section which is the target of this
-internal link \ref{subsection-1-1}.
-
-\end{document}
-"""],
-]
-
-# ==============================================================
-
-totest['seealso'] = [
-# input
-[rest_head + r"""
-See Also
-========
-
-`Docutils: Python Documentation Utilities`_
-
-.. _`Docutils: Python Documentation Utilities`:
- http://docutils.sourceforge.net/
-
-""",
-
-# expected output
-latex_head + r"""
-%___________________________________________________________________________
-
-\section{1   See Also\label{see-also}}
-
-\ulink{Docutils: Python Documentation Utilities}{http://docutils.sourceforge.net/}
-
-\end{document}
-"""],
-]
-
-
-# ==============================================================
-
-totest['emphasis'] = [
-# input
-[rest_head + r"""
-Section #1
-==========
-
-This section contains *some emphaized text*.
-
-It **also has some bold text**.
-
-And ``this is sample text``, or, as it is known in reStructured
-Text, an in-line literal.
-
-""",
-
-# expected output
-latex_head + r"""
-%___________________________________________________________________________
-
-\section{1   Section {\#}1\label{section-1}}
-
-This section contains \emph{some emphaized text}.
-
-It \strong{also has some bold text}.
-
-And \samp{this is sample text}, or, as it is known in reStructured
-Text, an in-line literal.
-
-\end{document}
-"""],
-]
-
-
-# ==============================================================
-
-totest['blockquote'] = [
-# input
-[rest_head + r"""
-Block Quote Test
-================
-
-This section contains a paragraph which is followed by a block
-quote. The block quote is a simple paragraph that is indented.
-
- This is the block quoted paragraph. It has several sentences.
- These sentences have empty content because they are only a
- test. This is a test. This is a test. This is a test. This
- is a test. This is a test. This is a test.
-
-
-Python Iteractive Session Test
-==============================
-
-This section has a Python interactive session. It is a test.
-Here is the example session.
-
->>> import sys
->>> print sys.version
-2.3 (#1, Jul 31 2003, 15:26:15)
-[GCC 3.2.3 20030415 (Debian prerelease)]
->>> a = [11,22,33]
->>> for x in a:
-... print x
-...
-11
-22
-33
-
-
-Literal Block Test
-==================
-
-This section has a literal block. In Python LaTeX it will be
-formatted in a verbatim environment::
-
- def remove_lines(self, inStr, targetList):
- inLines = inStr.splitlines()
- outLines = []
- for line in inLines:
- remove = False
- for target in targetList:
- if line.find(target) > -1:
- remove = True
- if not remove:
- outLines.append(line)
- outStr = '\n'.join(outLines)
- return outStr
-
-""",
-
-# expected output
-latex_head + r"""
-%___________________________________________________________________________
-
-\section{1   Block Quote Test\label{block-quote-test}}
-
-This section contains a paragraph which is followed by a block
-quote. The block quote is a simple paragraph that is indented.
-\begin{quote}
-
-This is the block quoted paragraph. It has several sentences.
-These sentences have empty content because they are only a
-test. This is a test. This is a test. This is a test. This
-is a test. This is a test. This is a test.
-\end{quote}
-
-
-%___________________________________________________________________________
-
-\section{2   Python Iteractive Session Test\label{python-iteractive-session-test}}
-
-This section has a Python interactive session. It is a test.
-Here is the example session.
-\begin{verbatim}
->>> import sys
->>> print sys.version
-2.3 (#1, Jul 31 2003, 15:26:15)
-[GCC 3.2.3 20030415 (Debian prerelease)]
->>> a = [11,22,33]
->>> for x in a:
-... print x
-...
-11
-22
-33
-\end{verbatim}
-
-
-%___________________________________________________________________________
-
-\section{3   Literal Block Test\label{literal-block-test}}
-
-This section has a literal block. In Python LaTeX it will be
-formatted in a verbatim environment:
-
-\begin{verbatim}
-def remove_lines(self, inStr, targetList):
- inLines = inStr.splitlines()
- outLines = []
- for line in inLines:
- remove = False
- for target in targetList:
- if line.find(target) > -1:
- remove = True
- if not remove:
- outLines.append(line)
- outStr = '\n'.join(outLines)
- return outStr
-\end{verbatim}
-
-\end{document}
-"""],
-]
-
-
-# ==============================================================
-
-if __name__ == '__main__':
- import unittest
- unittest.main(defaultTest='suite')
-
-
-
-
-