diff options
Diffstat (limited to 'docutils/test/test_readers/test_python')
| -rw-r--r-- | docutils/test/test_readers/test_python/.cvsignore | 1 | ||||
| -rw-r--r-- | docutils/test/test_readers/test_python/__init__.py | 14 | ||||
| -rw-r--r-- | docutils/test/test_readers/test_python/test_functions.py | 58 |
3 files changed, 73 insertions, 0 deletions
diff --git a/docutils/test/test_readers/test_python/.cvsignore b/docutils/test/test_readers/test_python/.cvsignore new file mode 100644 index 000000000..0d20b6487 --- /dev/null +++ b/docutils/test/test_readers/test_python/.cvsignore @@ -0,0 +1 @@ +*.pyc diff --git a/docutils/test/test_readers/test_python/__init__.py b/docutils/test/test_readers/test_python/__init__.py new file mode 100644 index 000000000..2fe79c55c --- /dev/null +++ b/docutils/test/test_readers/test_python/__init__.py @@ -0,0 +1,14 @@ +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/test_functions.py b/docutils/test/test_readers/test_python/test_functions.py new file mode 100644 index 000000000..6cee74502 --- /dev/null +++ b/docutils/test/test_readers/test_python/test_functions.py @@ -0,0 +1,58 @@ +#! /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 second line. + + Middle line indented. + + Last line unindented.""", + """All on one line.""") + expected = ("""""", # empty + """\ +Begins on the first line. + + Middle line indented. + +Last line unindented.""", + """\ +Begins on the second line. + + Middle line indented. + +Last line unindented.""", + """All on one line.""") + + def test_trim_docstring(self): + for i in range(len(self.docstrings)): + self.assertEquals(trim_docstring(self.docstrings[i]), + self.expected[i]) + self.assertEquals(trim_docstring('\n ' + self.docstrings[i]), + self.expected[i]) + + +if __name__ == '__main__': + unittest.main() |
