diff options
| author | goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2002-12-12 03:25:41 +0000 |
|---|---|---|
| committer | goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2002-12-12 03:25:41 +0000 |
| commit | fd4896590acd847e7bc9a272f928cdaa00c4ecec (patch) | |
| tree | 1cc9a1be1a5330bb677ce58baac2d14c1f177bdd /docutils/test/test_readers/test_python | |
| parent | fb7e24509f5b3dfe4aed920488c90975f6d6300b (diff) | |
| download | docutils-fd4896590acd847e7bc9a272f928cdaa00c4ecec.tar.gz | |
updated
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@1016 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/test/test_readers/test_python')
| -rwxr-xr-x | docutils/test/test_readers/test_python/showtok | 2 | ||||
| -rw-r--r-- | docutils/test/test_readers/test_python/test_functions.py | 42 | ||||
| -rw-r--r-- | docutils/test/test_readers/test_python/test_parser.py | 68 |
3 files changed, 78 insertions, 34 deletions
diff --git a/docutils/test/test_readers/test_python/showtok b/docutils/test/test_readers/test_python/showtok index b2b750514..efd250ce1 100755 --- a/docutils/test/test_readers/test_python/showtok +++ b/docutils/test/test_readers/test_python/showtok @@ -26,7 +26,7 @@ import test_parser def name_tokens(tokens): for i in range(len(tokens)): tup = tokens[i] - tokens[i] = (tok_name[tup[0]],) + tup + tokens[i] = (tok_name[tup[0]], tup) if len(sys.argv) > 1: key, caseno = sys.argv[1:] diff --git a/docutils/test/test_readers/test_python/test_functions.py b/docutils/test/test_readers/test_python/test_functions.py index 6cee74502..c219517d0 100644 --- a/docutils/test/test_readers/test_python/test_functions.py +++ b/docutils/test/test_readers/test_python/test_functions.py @@ -12,46 +12,48 @@ Tests for PySource Reader functions. import unittest from __init__ import DocutilsTestSupport -from docutils.readers.python.moduleparser import trim_docstring +from docutils.readers.python.moduleparser import trim_docstring, TokenReader class MiscTests(unittest.TestCase): - docstrings = ("""""", # empty - """Begins on the first line. + 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.""", - """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.""") +Last line unindented."""), + ("""All on one line.""", """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]) + for docstring, expected in self.docstrings: + self.assertEquals(trim_docstring(docstring), expected) + self.assertEquals(trim_docstring('\n ' + docstring), + expected) + +# def test_token_reader(self): +# tr = TokenReader('a = 1') +# self.assertEquals(tr.rhs('a', 1), '1') if __name__ == '__main__': diff --git a/docutils/test/test_readers/test_python/test_parser.py b/docutils/test/test_readers/test_python/test_parser.py index 8e4509118..0621337de 100644 --- a/docutils/test/test_readers/test_python/test_parser.py +++ b/docutils/test/test_readers/test_python/test_parser.py @@ -139,6 +139,15 @@ from module import name as local 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 ''', '''\ @@ -179,7 +188,7 @@ from __future__ import division # '''\ # <Module filename="test data"> # <Attribute lineno="1" name="a"> -# <Expression> +# <Expression lineno="1"> # 1 # '''], # ['''\ @@ -189,7 +198,7 @@ from __future__ import division # '''\ # <Module filename="test data"> # <Attribute lineno="1" name="a"> -# <Expression> +# <Expression lineno="1"> # 1 # <Docstring lineno="2"> # a's docstring @@ -202,7 +211,7 @@ from __future__ import division # '''\ # <Module filename="test data"> # <Attribute lineno="1" name="a"> -# <Expression> +# <Expression lineno="1"> # 1 # <Docstring lineno="2"> # a's docstring @@ -210,13 +219,13 @@ from __future__ import division # additional docstring # '''], #' # ['''\ -# a = 1 + 2 +# a = 1 + 2 * 3 / 4 ** 5 # ''', # '''\ # <Module filename="test data"> # <Attribute lineno="1" name="a"> -# <Expression> -# 1 + 2 +# <Expression lineno="1"> +# 1 + 2 * 3 / 4 ** 5 # '''], # ['''\ # a = 1 \\ @@ -225,17 +234,44 @@ from __future__ import division # '''\ # <Module filename="test data"> # <Attribute lineno="1" name="a"> -# <Expression> +# <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> +# <Expression lineno="1"> # x # '''], # ['''\ @@ -245,7 +281,7 @@ from __future__ import division # '''\ # <Module filename="test data"> # <Attribute lineno="1" name="very_long_name"> -# <Expression> +# <Expression lineno="1"> # x # '''], # ['''\ @@ -256,7 +292,7 @@ from __future__ import division # '''\ # <Module filename="test data"> # <Attribute lineno="1" name="very_long_name"> -# <Expression> +# <Expression lineno="1"> # x # '''], # ['''\ @@ -273,13 +309,13 @@ from __future__ import division # '''\ # <Module filename="test data"> # <Attribute lineno="1" name="a"> -# <Expression> +# <Expression lineno="1"> # (1 + 2) # <Attribute lineno="3" name="b"> -# <Expression> +# <Expression lineno="3"> # a.b[1 + fn(x, y, z, {'key': (1 + 2 + 3)})] # <Attribute lineno="7" name="c"> -# <Expression> +# <Expression lineno="7"> # """first line\\nsecond line\\n third""" # '''], # ['''\ @@ -307,6 +343,12 @@ totest['ignore'] = [ '''\ <Module filename="test data"> '''], +['''\ +del a +''', +'''\ +<Module filename="test data"> +'''], ] """ |
