From ac4482de12677c0dd4ea8fef3eba7b306bbc262f Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 5 Dec 2002 02:32:25 +0000 Subject: initial checkin git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@991 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/.cvsignore | 1 + test/test_readers/test_python/__init__.py | 14 ++++++ test/test_readers/test_python/test_functions.py | 58 +++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 test/test_readers/test_python/.cvsignore create mode 100644 test/test_readers/test_python/__init__.py create mode 100644 test/test_readers/test_python/test_functions.py (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/.cvsignore b/test/test_readers/test_python/.cvsignore new file mode 100644 index 000000000..0d20b6487 --- /dev/null +++ b/test/test_readers/test_python/.cvsignore @@ -0,0 +1 @@ +*.pyc diff --git a/test/test_readers/test_python/__init__.py b/test/test_readers/test_python/__init__.py new file mode 100644 index 000000000..2fe79c55c --- /dev/null +++ b/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/test/test_readers/test_python/test_functions.py b/test/test_readers/test_python/test_functions.py new file mode 100644 index 000000000..6cee74502 --- /dev/null +++ b/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() -- cgit v1.2.1 From aca5c76ca83092f1e5f9963aacd4884f64fe0e3d Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 5 Dec 2002 02:41:35 +0000 Subject: Tests for docutils/readers/python/moduleparser.py. Tests that don't pass yet are commented out. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@995 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/test_parser.py | 321 +++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 test/test_readers/test_python/test_parser.py (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/test_parser.py b/test/test_readers/test_python/test_parser.py new file mode 100644 index 000000000..8e4509118 --- /dev/null +++ b/test/test_readers/test_python/test_parser.py @@ -0,0 +1,321 @@ +#! /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'] = [ +['''\ +''', +'''\ + +'''], +['''\ +"""docstring""" +''', +'''\ + + + docstring +'''], +['''\ +u"""Unicode docstring""" +''', +'''\ + + + Unicode docstring +'''], +['''\ +"""docstring""" +"""additional docstring""" +''', +'''\ + + + docstring + + additional docstring +'''], +['''\ +"""docstring""" +# comment +"""additional docstring""" +''', +'''\ + + + docstring + + additional docstring +'''], +['''\ +"""docstring""" +1 +"""not an additional docstring""" +''', +'''\ + + + docstring +'''], +] + +totest['import'] = [ +['''\ +import module +''', +'''\ + + + module +'''], +['''\ +import module as local +''', +'''\ + + + module as local +'''], +['''\ +import module.name +''', +'''\ + + + module.name +'''], +['''\ +import module.name as local +''', +'''\ + + + module.name as local +'''], +['''\ +import module +"""not documentable""" +''', +'''\ + + + module +'''], +] + +totest['from'] = [ +['''\ +from module import name +''', +'''\ + + + name +'''], +['''\ +from module import name as local +''', +'''\ + + + name as local +'''], +['''\ +from module.sub import name +''', +'''\ + + + name +'''], +['''\ +from module.sub import name as local +''', +'''\ + + + name as local +'''], +['''\ +from module import * +''', +'''\ + + + * +'''], +['''\ +from __future__ import division +''', +'''\ + + + division +'''], +] + +# totest['assign'] = [ +# ['''\ +# a = 1 +# ''', +# '''\ +# +# +# +# 1 +# '''], +# ['''\ +# a = 1 +# """a's docstring""" +# ''', #" +# '''\ +# +# +# +# 1 +# +# a's docstring +# '''], #' +# ['''\ +# a = 1 +# """a's docstring""" +# """additional docstring""" +# ''', #" +# '''\ +# +# +# +# 1 +# +# a's docstring +# +# additional docstring +# '''], #' +# ['''\ +# a = 1 + 2 +# ''', +# '''\ +# +# +# +# 1 + 2 +# '''], +# ['''\ +# a = 1 \\ +# + 2 +# ''', +# '''\ +# +# +# +# 1 + 2 +# '''], +# ['''\ +# very_long_name = \\ +# x +# ''', +# '''\ +# +# +# +# x +# '''], +# ['''\ +# very_long_name \\ +# = x +# ''', +# '''\ +# +# +# +# x +# '''], +# ['''\ +# very_long_name = \\ +# another_long_name = \\ +# x +# ''', +# '''\ +# +# +# +# x +# '''], +# ['''\ +# a = (1 +# + 2) +# b = a.b[1 + +# fn(x, y, +# z, {'key': (1 + 2 +# + 3)})] +# c = """first line +# second line +# third""" +# ''', +# '''\ +# +# +# +# (1 + 2) +# +# +# a.b[1 + fn(x, y, z, {'key': (1 + 2 + 3)})] +# +# +# """first line\\nsecond line\\n third""" +# '''], +# ['''\ +# a, b, c = range(3) +# (d, e, +# f) = a, b, c +# ''', +# '''\ +# '''], +# ] + +# totest['def'] = [ +# ['''\ +# def f(): +# pass +# ''', +# '''\ +# '''], +# ] + +totest['ignore'] = [ +['''\ +1 + 2 +''', +'''\ + +'''], +] + +""" +['''\ +''', +'''\ +'''], +""" + +if __name__ == '__main__': + import unittest + unittest.main(defaultTest='suite') -- cgit v1.2.1 From aa176e1c0fae4fcfb219964b527cc29a40e2fee6 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 6 Dec 2002 02:39:38 +0000 Subject: a tool for exploring abstract syntax trees generated by ``compiler.parse()`` git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@997 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/showast | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 test/test_readers/test_python/showast (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/showast b/test/test_readers/test_python/showast new file mode 100755 index 000000000..2bb4ad3a6 --- /dev/null +++ b/test/test_readers/test_python/showast @@ -0,0 +1,51 @@ +#! /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. + +Usage:: + + showast + +Where ```` is the key to the ``totest`` dictionary, and ```` is +the index of the list ``totest[key]``. +""" + +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 + +key, caseno = sys.argv[1:] +print 'totest["%s"][%s][0]:\n' % (key, caseno) +input_text = test_parser.totest[key][int(caseno)][0] +print input_text +module = compiler.parse(input_text) +print module +print +print ''.join(pformat(module)), -- cgit v1.2.1 From 5b8a02bdadf2a3f6096e6c412beeac81ddb99b20 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 6 Dec 2002 02:40:01 +0000 Subject: a tool for exploring abstract syntax trees generated by ``parser.suite()`` git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@998 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/showparse | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 test/test_readers/test_python/showparse (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/showparse b/test/test_readers/test_python/showparse new file mode 100755 index 000000000..61e08ba92 --- /dev/null +++ b/test/test_readers/test_python/showparse @@ -0,0 +1,42 @@ +#! /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. + +Usage:: + + showparse + +Where ```` is the key to the ``totest`` dictionary, and ```` is +the index of the list ``totest[key]``. +""" + +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) + +key, caseno = sys.argv[1:] +print 'totest["%s"][%s][0]:\n' % (key, caseno) +input_text = test_parser.totest[key][int(caseno)][0] +print input_text +module = parser.suite(input_text) +ast = parser.ast2list(module, line_info=1) +name_elements(ast) +pprint.pprint(ast) -- cgit v1.2.1 From 137b35650bd5ef8b13d10a91e9ca7d1ae81e214f Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 6 Dec 2002 02:40:30 +0000 Subject: a tool for exploring abstract syntax trees generated by ``tokenize.generate_tokens()`` git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@999 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/showtok | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 test/test_readers/test_python/showtok (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/showtok b/test/test_readers/test_python/showtok new file mode 100755 index 000000000..b844b6bc0 --- /dev/null +++ b/test/test_readers/test_python/showtok @@ -0,0 +1,34 @@ +#! /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. + +Usage:: + + showtok + +Where ```` is the key to the ``totest`` dictionary, and ```` is +the index of the list ``totest[key]``. +""" + +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 + +key, caseno = sys.argv[1:] +print 'totest["%s"][%s][0]:\n' % (key, caseno) +input_text = test_parser.totest[key][int(caseno)][0] +print input_text +tokens = list(tokenize.generate_tokens(iter(input_text.splitlines(1)).next)) +name_tokens(tokens) +pprint.pprint(tokens) -- cgit v1.2.1 From eba59e0b9f6ca9ac58e7423eaa1592cf4c928096 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 7 Dec 2002 03:02:18 +0000 Subject: added stdin input capability git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1001 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/showast | 16 +++++++++++----- test/test_readers/test_python/showparse | 16 +++++++++++----- test/test_readers/test_python/showtok | 16 +++++++++++----- 3 files changed, 33 insertions(+), 15 deletions(-) (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/showast b/test/test_readers/test_python/showast index 2bb4ad3a6..e7d846307 100755 --- a/test/test_readers/test_python/showast +++ b/test/test_readers/test_python/showast @@ -3,14 +3,17 @@ """ 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. +docutils/test/test_readers/test_python/test_parser or stdin. Usage:: showast + showast < + Where ```` is the key to the ``totest`` dictionary, and ```` is -the index of the list ``totest[key]``. +the index of the list ``totest[key]``. If no arguments are given, stdin is +used for input. """ import sys @@ -41,9 +44,12 @@ def pformat(ast, indent=' ', level=0): result.extend(pformat(node, level=level+1)) return result -key, caseno = sys.argv[1:] -print 'totest["%s"][%s][0]:\n' % (key, caseno) -input_text = test_parser.totest[key][int(caseno)][0] +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 diff --git a/test/test_readers/test_python/showparse b/test/test_readers/test_python/showparse index 61e08ba92..8144256d6 100755 --- a/test/test_readers/test_python/showparse +++ b/test/test_readers/test_python/showparse @@ -3,14 +3,17 @@ """ 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. +docutils/test/test_readers/test_python/test_parser or stdin. Usage:: showparse + showparse < + Where ```` is the key to the ``totest`` dictionary, and ```` is -the index of the list ``totest[key]``. +the index of the list ``totest[key]``. If no arguments are given, stdin is +used for input. """ import sys @@ -32,9 +35,12 @@ def name_elements(ast): if type(node) == types.ListType: name_elements(node) -key, caseno = sys.argv[1:] -print 'totest["%s"][%s][0]:\n' % (key, caseno) -input_text = test_parser.totest[key][int(caseno)][0] +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) diff --git a/test/test_readers/test_python/showtok b/test/test_readers/test_python/showtok index b844b6bc0..b2b750514 100755 --- a/test/test_readers/test_python/showtok +++ b/test/test_readers/test_python/showtok @@ -4,14 +4,17 @@ """ 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. +docutils/test/test_readers/test_python/test_parser or stdin. Usage:: showtok + showtok < + Where ```` is the key to the ``totest`` dictionary, and ```` is -the index of the list ``totest[key]``. +the index of the list ``totest[key]``. If no arguments are given, stdin is +used for input. """ import sys @@ -25,9 +28,12 @@ def name_tokens(tokens): tup = tokens[i] tokens[i] = (tok_name[tup[0]],) + tup -key, caseno = sys.argv[1:] -print 'totest["%s"][%s][0]:\n' % (key, caseno) -input_text = test_parser.totest[key][int(caseno)][0] +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) -- cgit v1.2.1 From f4a682232afed2927fee6f572267b87559fa417b Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 12 Dec 2002 03:25:41 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1016 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/showtok | 2 +- test/test_readers/test_python/test_functions.py | 42 +++++++-------- test/test_readers/test_python/test_parser.py | 68 ++++++++++++++++++++----- 3 files changed, 78 insertions(+), 34 deletions(-) (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/showtok b/test/test_readers/test_python/showtok index b2b750514..efd250ce1 100755 --- a/test/test_readers/test_python/showtok +++ b/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/test/test_readers/test_python/test_functions.py b/test/test_readers/test_python/test_functions.py index 6cee74502..c219517d0 100644 --- a/test/test_readers/test_python/test_functions.py +++ b/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/test/test_readers/test_python/test_parser.py b/test/test_readers/test_python/test_parser.py index 8e4509118..0621337de 100644 --- a/test/test_readers/test_python/test_parser.py +++ b/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 +''', +'''\ + + + name1 + name2 as local2 +'''], +['''\ from module.sub import name ''', '''\ @@ -179,7 +188,7 @@ from __future__ import division # '''\ # # -# +# # 1 # '''], # ['''\ @@ -189,7 +198,7 @@ from __future__ import division # '''\ # # -# +# # 1 # # a's docstring @@ -202,7 +211,7 @@ from __future__ import division # '''\ # # -# +# # 1 # # a's docstring @@ -210,13 +219,13 @@ from __future__ import division # additional docstring # '''], #' # ['''\ -# a = 1 + 2 +# a = 1 + 2 * 3 / 4 ** 5 # ''', # '''\ # # -# -# 1 + 2 +# +# 1 + 2 * 3 / 4 ** 5 # '''], # ['''\ # a = 1 \\ @@ -225,17 +234,44 @@ from __future__ import division # '''\ # # -# +# # 1 + 2 # '''], # ['''\ +# a = not 1 and 2 or 3 +# ''', +# '''\ +# +# +# +# not 1 and 2 or 3 +# '''], +# ['''\ +# a = ~ 1 & 2 | 3 ^ 4 +# ''', +# '''\ +# +# +# +# ~ 1 & 2 | 3 ^ 4 +# '''], +# ['''\ +# a = `1 & 2` +# ''', +# '''\ +# +# +# +# `1 & 2` +# '''], +# ['''\ # very_long_name = \\ # x # ''', # '''\ # # -# +# # x # '''], # ['''\ @@ -245,7 +281,7 @@ from __future__ import division # '''\ # # -# +# # x # '''], # ['''\ @@ -256,7 +292,7 @@ from __future__ import division # '''\ # # -# +# # x # '''], # ['''\ @@ -273,13 +309,13 @@ from __future__ import division # '''\ # # -# +# # (1 + 2) # -# +# # a.b[1 + fn(x, y, z, {'key': (1 + 2 + 3)})] # -# +# # """first line\\nsecond line\\n third""" # '''], # ['''\ @@ -307,6 +343,12 @@ totest['ignore'] = [ '''\ '''], +['''\ +del a +''', +'''\ + +'''], ] """ -- cgit v1.2.1 From 47ff214eaec8f59ac08c78614811e12eb9b06fde Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 14 Dec 2002 01:38:31 +0000 Subject: making good progress git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1020 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/test_functions.py | 6 +- test/test_readers/test_python/test_parser.py | 428 ++++++++++++++------- test/test_readers/test_python/test_token_parser.py | 46 +++ 3 files changed, 335 insertions(+), 145 deletions(-) create mode 100644 test/test_readers/test_python/test_token_parser.py (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/test_functions.py b/test/test_readers/test_python/test_functions.py index c219517d0..d521b2203 100644 --- a/test/test_readers/test_python/test_functions.py +++ b/test/test_readers/test_python/test_functions.py @@ -12,7 +12,7 @@ Tests for PySource Reader functions. import unittest from __init__ import DocutilsTestSupport -from docutils.readers.python.moduleparser import trim_docstring, TokenReader +from docutils.readers.python.moduleparser import trim_docstring class MiscTests(unittest.TestCase): @@ -51,10 +51,6 @@ Last line unindented."""), 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__': unittest.main() diff --git a/test/test_readers/test_python/test_parser.py b/test/test_readers/test_python/test_parser.py index 0621337de..f45bb6ad1 100644 --- a/test/test_readers/test_python/test_parser.py +++ b/test/test_readers/test_python/test_parser.py @@ -181,160 +181,308 @@ from __future__ import division '''], ] -# totest['assign'] = [ -# ['''\ -# a = 1 -# ''', -# '''\ -# -# -# -# 1 -# '''], -# ['''\ -# a = 1 -# """a's docstring""" -# ''', #" -# '''\ -# -# -# -# 1 -# -# a's docstring -# '''], #' -# ['''\ -# a = 1 -# """a's docstring""" -# """additional docstring""" -# ''', #" -# '''\ -# -# -# -# 1 -# -# a's docstring -# -# additional docstring -# '''], #' -# ['''\ -# a = 1 + 2 * 3 / 4 ** 5 -# ''', -# '''\ -# -# -# -# 1 + 2 * 3 / 4 ** 5 -# '''], -# ['''\ -# a = 1 \\ -# + 2 -# ''', -# '''\ -# -# -# -# 1 + 2 -# '''], -# ['''\ -# a = not 1 and 2 or 3 -# ''', -# '''\ -# -# -# -# not 1 and 2 or 3 -# '''], -# ['''\ -# a = ~ 1 & 2 | 3 ^ 4 -# ''', -# '''\ -# -# -# -# ~ 1 & 2 | 3 ^ 4 -# '''], -# ['''\ -# a = `1 & 2` -# ''', -# '''\ -# -# -# -# `1 & 2` -# '''], -# ['''\ -# very_long_name = \\ -# x -# ''', -# '''\ -# -# -# -# x -# '''], -# ['''\ -# very_long_name \\ -# = x -# ''', -# '''\ -# -# -# -# x -# '''], +totest['assign'] = [ +['''\ +a = 1 +''', +'''\ + + + + 1 +'''], +['''a = 1''', +'''\ + + + + 1 +'''], +['''\ +a = 1 +"""a's docstring""" +''', #" +'''\ + + + + 1 + + a's docstring +'''], #' +['''\ +a = 1 +"""a's docstring""" +"""additional docstring""" +''', #" +'''\ + + + + 1 + + a's docstring + + additional docstring +'''], #' +['''\ +a = 1 + 2 * 3 / 4 ** 5 +''', +'''\ + + + + 1 + 2 * 3 / 4 ** 5 +'''], +['''\ +a = 1 \\ + + 2 +''', +'''\ + + + + 1 + 2 +'''], +['''\ +a = not 1 and 2 or 3 +''', +'''\ + + + + not 1 and 2 or 3 +'''], +['''\ +a = ~ 1 & 2 | 3 ^ 4 +''', +'''\ + + + + ~ 1 & 2 | 3 ^ 4 +'''], +['''\ +a = `1 & 2` +''', +'''\ + + + + `1 & 2` +'''], +['''\ +very_long_name = \\ + x +''', +'''\ + + + + x +'''], +['''\ +very_long_name \\ + = x +''', +'''\ + + + + x +'''], +['''\ +very_long_name = \\ + another_long_name = \\ + x +''', +'''\ + + + + x + + + x +'''], +['''\ +a = (1 + + 2) +b = a.b[1 + + fn(x, y, + z, {'key': (1 + 2 + + 3)})][4] +c = """first line +second line + third""" +''', +'''\ + + + + (1 + 2) + + + a.b[1 + fn(x, y, z, {'key': (1 + 2 + 3)})][4] + + + """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 +''', +'''\ + + + + range(3) + + + a, b, c + + + a, b, c + + + a, b, c + + + a, b, c +'''], +['''\ +a = 1 ; b = 2 +print ; c = 3 +''', +'''\ + + + + 1 + + + 2 + + + 3 +'''], +['''\ +a.b = 1 +"""This assignment is noted but ignored unless ``a`` is a function.""" +''', +'''\ + + + + 1 + + This assignment is noted but ignored unless ``a`` is a function. +'''], +['''\ +a[b] = 1 +"""This assignment is noted but ignored unless ``a`` is a function.""" +''', +'''\ + +'''], +] + +totest['def'] = [ +['''\ +def f(): + """Function f's docstring""" + """Additional docstring""" + local = 1 + """Not a docstring, since ``local`` is local.""" +''', # " +'''\ + + + + Function f's docstring + + Additional docstring +'''], # ' +['''\ +def f(a, b): + local = 1 +''', +'''\ + + + + + +'''], # ['''\ -# very_long_name = \\ -# another_long_name = \\ -# x +# def f(a=None, b=1): +# local = 1 # ''', # '''\ # -# -# -# x +# +# +# +# +# None +# +# +# 1 # '''], +['''\ +def f(*args): + local = 1 +''', +'''\ + + + + +'''], +['''\ +def f(**kwargs): + local = 1 +''', +'''\ + + + + +'''], # ['''\ -# a = (1 -# + 2) -# b = a.b[1 + -# fn(x, y, -# z, {'key': (1 + 2 -# + 3)})] -# c = """first line -# second line -# third""" +# def f(a, b=None, *args, **kwargs): +# local = 1 # ''', # '''\ # -# -# -# (1 + 2) -# -# -# a.b[1 + fn(x, y, z, {'key': (1 + 2 + 3)})] -# -# -# """first line\\nsecond line\\n third""" +# +# +# +# +# +# None +# +# # '''], # ['''\ -# a, b, c = range(3) -# (d, e, -# f) = a, b, c -# ''', -# '''\ -# '''], -# ] - -# totest['def'] = [ -# ['''\ # def f(): # pass -# ''', +# f.attrib = 1 +# """f.attrib's docstring""" +# ''', # " # '''\ -# '''], -# ] +# +# +# +# +# 1 +# +# f.attrib's docstring +# '''], # ' +] totest['ignore'] = [ ['''\ diff --git a/test/test_readers/test_python/test_token_parser.py b/test/test_readers/test_python/test_token_parser.py new file mode 100644 index 000000000..23015a7dc --- /dev/null +++ b/test/test_readers/test_python/test_token_parser.py @@ -0,0 +1,46 @@ +#! /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') -- cgit v1.2.1 From 173c7a539ca4e2b3a9f8c3a06f67d4a868fd850c Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 18 Dec 2002 01:44:49 +0000 Subject: More progress; functions done. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1027 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/test_parser.py | 118 +++++++++++++++++---------- 1 file changed, 73 insertions(+), 45 deletions(-) (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/test_parser.py b/test/test_readers/test_python/test_parser.py index f45bb6ad1..021ad3438 100644 --- a/test/test_readers/test_python/test_parser.py +++ b/test/test_readers/test_python/test_parser.py @@ -417,21 +417,38 @@ def f(a, b): '''], -# ['''\ -# def f(a=None, b=1): -# local = 1 -# ''', -# '''\ -# -# -# -# -# -# None -# -# -# 1 -# '''], +['''\ +def f(a=None, b=1): + local = 1 +''', +'''\ + + + + + + None + + + 1 +'''], +['''\ +def f(a, (b, c, d)=range(3), + e=None): + local = 1 +''', +'''\ + + + + + + + range(3) + + + None +'''], ['''\ def f(*args): local = 1 @@ -452,36 +469,47 @@ def f(**kwargs): '''], -# ['''\ -# def f(a, b=None, *args, **kwargs): -# local = 1 -# ''', -# '''\ -# -# -# -# -# -# -# None -# -# -# '''], -# ['''\ -# def f(): -# pass -# f.attrib = 1 -# """f.attrib's docstring""" -# ''', # " -# '''\ -# -# -# -# -# 1 -# -# f.attrib's docstring -# '''], # ' +['''\ +def f(a, b=None, *args, **kwargs): + local = 1 +''', +'''\ + + + + + + + None + + +'''], +['''\ +def f(): + pass +f.attrib = 1 +"""f.attrib's docstring""" +''', # " +# @@@ When should the Attribute move inside the Function? +'''\ + + + + + 1 + + f.attrib's docstring +'''], # ' +['''\ +def f(): + def g(): + pass + local = 1 +''', +'''\ + + +'''], ] totest['ignore'] = [ -- cgit v1.2.1 From f5260b063daae93f15562361988e5f3902d88625 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 19 Dec 2002 00:53:54 +0000 Subject: a tool for exploring module documentation trees generated by ``docutils.readers.python.moduleparser.parse_module()`` git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1031 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/showdoc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 test/test_readers/test_python/showdoc (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/showdoc b/test/test_readers/test_python/showdoc new file mode 100755 index 000000000..6461960f8 --- /dev/null +++ b/test/test_readers/test_python/showdoc @@ -0,0 +1,33 @@ +#! /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 + + showdoc < + +Where ```` is the key to the ``totest`` dictionary, and ```` 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 = '' +print input_text +module = parse_module(input_text, input_source) +print module, -- cgit v1.2.1 From 34762d707e5fbe502b302027e4318c8301d7a34d Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 19 Dec 2002 01:08:01 +0000 Subject: Added classes & methods. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1032 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/test_parser.py | 158 +++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/test_parser.py b/test/test_readers/test_python/test_parser.py index 021ad3438..eedde804f 100644 --- a/test/test_readers/test_python/test_parser.py +++ b/test/test_readers/test_python/test_parser.py @@ -504,6 +504,7 @@ f.attrib = 1 def f(): def g(): pass + """Not a docstring""" local = 1 ''', '''\ @@ -512,6 +513,73 @@ def f(): '''], ] +totest['class'] = [ +['''\ +class C: + """class C's docstring""" +''', +'''\ + + + + class C's docstring +'''], +['''\ +class C(Super): + pass + +class D(SuperD, package.module.SuperD): + pass +''', +'''\ + + + +'''], +['''\ +class C: + class D: + pass + """Not a docstring""" +''', +'''\ + + +'''], +['''\ +class C: + def f(self): + self.local = 1 + local = 1 +''', +'''\ + + + + + +'''], +['''\ +class C: + def __init__(self): + self.local = 1 + local = 1 +''', +'''\ + + + + + + + + 1 + + + 1 +'''], +] + totest['ignore'] = [ ['''\ 1 + 2 @@ -527,6 +595,96 @@ del a '''], ] +# @@@ 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""" +''', +'''\ + + + Docstring + + Additional docstring + + + 'reStructuredText' + + + 1 + + Attribute docstring + + + C's docstring + + + 1 + + class_attribute's docstring + + + __init__'s docstring + + + + + None + + + (text * 7 + ' whaddyaknow') + + instance_attribute's docstring + + + f's docstring + + + + + a * 5 + + + + 1 + + f.function_attribute's docstring +'''], +] + """ ['''\ ''', -- cgit v1.2.1 From 1657a66e02a6e3ed275779e60a69ada497f25ad6 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 19 Dec 2002 03:36:05 +0000 Subject: added currently breaking expression git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1034 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/test_parser.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/test_parser.py b/test/test_readers/test_python/test_parser.py index eedde804f..0626b1a88 100644 --- a/test/test_readers/test_python/test_parser.py +++ b/test/test_readers/test_python/test_parser.py @@ -578,6 +578,21 @@ class C: 1 '''], +['''\ +class C: + def __init__(self): + local = foo(a = 1) +''', +'''\ + + + + + + + + foo(a = 1) +'''], ] totest['ignore'] = [ -- cgit v1.2.1 From 813520af216474ec5c97efb2b1809e38aa72b5d1 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 29 Dec 2002 18:38:06 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1046 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/test_parser.py | 39 +++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/test_parser.py b/test/test_readers/test_python/test_parser.py index 0626b1a88..ce70cc27c 100644 --- a/test/test_readers/test_python/test_parser.py +++ b/test/test_readers/test_python/test_parser.py @@ -383,11 +383,33 @@ a.b = 1 '''], ['''\ a[b] = 1 -"""This assignment is noted but ignored unless ``a`` is a function.""" +"""Subscript assignments are ignored.""" ''', '''\ '''], +['''\ +a = foo(b=1) +''', +'''\ + + + + foo(b=1) +'''], +# ['''\ +# a = 1 +# +# """Because of the blank above, this is a module docstring.""" +# ''', +# '''\ +# +# +# +# 1 +# +# Because of the blank above, this is a module docstring. +# '''], ] totest['def'] = [ @@ -581,7 +603,7 @@ class C: ['''\ class C: def __init__(self): - local = foo(a = 1) + local = foo(a=1) ''', '''\ @@ -591,7 +613,7 @@ class C: - foo(a = 1) + foo(a=1) '''], ] @@ -610,6 +632,17 @@ del a '''], ] +totest['comments'] = [ +# ['''\ +# # Comment +# ''', +# '''\ +# +# +# # Comment +# '''], +] + # @@@ no comments yet totest['everything'] = [ ['''\ -- cgit v1.2.1 From f6d2823bed3483be7c3a126c2499d7e9018fae8d Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 1 Jan 2003 02:41:16 +0000 Subject: redundant; CVSROOT/cvsignore is global git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1048 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/.cvsignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test/test_readers/test_python/.cvsignore (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/.cvsignore b/test/test_readers/test_python/.cvsignore deleted file mode 100644 index 0d20b6487..000000000 --- a/test/test_readers/test_python/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc -- cgit v1.2.1 From db10b42915077db1a6cbb936145d0d803142b12a Mon Sep 17 00:00:00 2001 From: ianbicking Date: Tue, 23 Mar 2004 19:57:14 +0000 Subject: * Bug fixes to python reader * Getting tests up-to-date * Trimming unused nodes from pynodes git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1876 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/test_parser.py | 778 ++++++++++++++++++--------- 1 file changed, 511 insertions(+), 267 deletions(-) (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/test_parser.py b/test/test_readers/test_python/test_parser.py index ce70cc27c..1ccfbdc10 100644 --- a/test/test_readers/test_python/test_parser.py +++ b/test/test_readers/test_python/test_parser.py @@ -24,22 +24,22 @@ totest['module'] = [ ['''\ ''', '''\ - + '''], ['''\ """docstring""" ''', '''\ - - + + docstring '''], ['''\ u"""Unicode docstring""" ''', '''\ - - + + Unicode docstring '''], ['''\ @@ -47,10 +47,10 @@ u"""Unicode docstring""" """additional docstring""" ''', '''\ - - + + docstring - + additional docstring '''], ['''\ @@ -59,10 +59,10 @@ u"""Unicode docstring""" """additional docstring""" ''', '''\ - - + + docstring - + additional docstring '''], ['''\ @@ -71,8 +71,8 @@ u"""Unicode docstring""" """not an additional docstring""" ''', '''\ - - + + docstring '''], ] @@ -82,42 +82,51 @@ totest['import'] = [ import module ''', '''\ - - - module + + + + module '''], ['''\ import module as local ''', '''\ - - - module as local + + + + module + + local '''], ['''\ import module.name ''', '''\ - - - module.name + + + + module.name '''], ['''\ import module.name as local ''', '''\ - - - module.name as local + + + + module.name + + local '''], ['''\ import module """not documentable""" ''', '''\ - - - module + + + + module '''], ] @@ -126,58 +135,86 @@ totest['from'] = [ from module import name ''', '''\ - - - name + + + + module + + name '''], ['''\ from module import name as local ''', '''\ - - - name as local + + + + module + + name + + local '''], ['''\ from module import name1, name2 as local2 ''', '''\ - - - name1 - name2 as local2 + + + + module + + name1 + + name2 + + local2 '''], ['''\ from module.sub import name ''', '''\ - - - name + + + + module.sub + + name '''], ['''\ from module.sub import name as local ''', '''\ - - - name as local + + + + module.sub + + name + + local '''], ['''\ from module import * ''', '''\ - - - * + + + + module + + * '''], ['''\ from __future__ import division ''', '''\ - - - division + + + + __future__ + + division '''], ] @@ -186,52 +223,62 @@ totest['assign'] = [ a = 1 ''', '''\ - - - + + + + a + 1 '''], ['''a = 1''', '''\ - - - + + + + a + 1 '''], ['''\ a = 1 -"""a's docstring""" +"""a docstring""" ''', #" '''\ - - - + + + + a + 1 - - a's docstring -'''], #' + + a docstring +'''], ['''\ a = 1 -"""a's docstring""" +"""a docstring""" """additional docstring""" ''', #" '''\ - - - + + + + a + 1 - - a's docstring - + + a docstring + additional docstring '''], #' ['''\ a = 1 + 2 * 3 / 4 ** 5 ''', '''\ - - - + + + + a + 1 + 2 * 3 / 4 ** 5 '''], ['''\ @@ -239,36 +286,44 @@ a = 1 \\ + 2 ''', '''\ - - - + + + + a + 1 + 2 '''], ['''\ a = not 1 and 2 or 3 ''', '''\ - - - + + + + a + not 1 and 2 or 3 '''], ['''\ a = ~ 1 & 2 | 3 ^ 4 ''', '''\ - - - + + + + a + ~ 1 & 2 | 3 ^ 4 '''], ['''\ a = `1 & 2` ''', '''\ - - - + + + + a + `1 & 2` '''], ['''\ @@ -276,9 +331,11 @@ very_long_name = \\ x ''', '''\ - - - + + + + very_long_name + x '''], ['''\ @@ -286,9 +343,11 @@ very_long_name \\ = x ''', '''\ - - - + + + + very_long_name + x '''], ['''\ @@ -297,12 +356,16 @@ very_long_name = \\ x ''', '''\ - - - + + + + very_long_name + x - - + + + another_long_name + x '''], ['''\ @@ -317,16 +380,24 @@ second line third""" ''', '''\ - - - + + + + a + (1 + 2) - - + + + b + a.b[1 + fn(x, y, z, {'key': (1 + 2 + 3)})][4] - - - """first line\\nsecond line\\n third""" + + + c + + """first line + second line + third""" '''], ['''\ a, b, c = range(3) @@ -336,21 +407,59 @@ g, h, i = j = a, b, c k.a, k.b.c, k.d.e.f = a, b, c ''', '''\ - - - + + + + + a + + + b + + + c + range(3) - - + + + + d + + + e + + + f + a, b, c - - + + + + g + + + h + + + i + a, b, c - - + + + j + a, b, c - - + + + + k.a + + + k.b.c + + + k.d.e.f + a, b, c '''], ['''\ @@ -358,15 +467,21 @@ a = 1 ; b = 2 print ; c = 3 ''', '''\ - - - + + + + a + 1 - - + + + b + 2 - - + + + c + 3 '''], ['''\ @@ -374,11 +489,13 @@ a.b = 1 """This assignment is noted but ignored unless ``a`` is a function.""" ''', '''\ - - - + + + + a.b + 1 - + This assignment is noted but ignored unless ``a`` is a function. '''], ['''\ @@ -386,15 +503,17 @@ a[b] = 1 """Subscript assignments are ignored.""" ''', '''\ - + '''], ['''\ a = foo(b=1) ''', '''\ - - - + + + + a + foo(b=1) '''], # ['''\ @@ -403,11 +522,13 @@ a = foo(b=1) # """Because of the blank above, this is a module docstring.""" # ''', # '''\ -# -# -# +# +# +# +# a +# # 1 -# +# # Because of the blank above, this is a module docstring. # '''], ] @@ -415,17 +536,19 @@ a = foo(b=1) totest['def'] = [ ['''\ def f(): - """Function f's docstring""" + """Function f docstring""" """Additional docstring""" local = 1 """Not a docstring, since ``local`` is local.""" ''', # " '''\ - - - - Function f's docstring - + + + + f + + Function f docstring + Additional docstring '''], # ' ['''\ @@ -433,25 +556,37 @@ def f(a, b): local = 1 ''', '''\ - - - - - + + + + f + + + + a + + + b '''], ['''\ def f(a=None, b=1): local = 1 ''', '''\ - - - - - + + + + f + + + + a + None - - + + + b + 1 '''], ['''\ @@ -460,15 +595,30 @@ def f(a, (b, c, d)=range(3), local = 1 ''', '''\ - - - - - - + + + + f + + + + a + + + + b + + + c + + + d + range(3) - - + + + e + None '''], ['''\ @@ -476,52 +626,74 @@ def f(*args): local = 1 ''', '''\ - - - - + + + + f + + + + args '''], ['''\ def f(**kwargs): local = 1 ''', '''\ - - - - + + + + f + + + + kwargs '''], ['''\ def f(a, b=None, *args, **kwargs): local = 1 ''', '''\ - - - - - - + + + + f + + + + a + + + b + None - - + + + args + + + kwargs '''], ['''\ def f(): pass f.attrib = 1 -"""f.attrib's docstring""" +"""f.attrib docstring""" ''', # " -# @@@ When should the Attribute move inside the Function? -'''\ - - - - +# @@@ When should the attribute move inside the Function? +'''\ + + + + f + + + f.attrib + 1 - - f.attrib's docstring -'''], # ' + + f.attrib docstring +'''], ['''\ def f(): def g(): @@ -530,21 +702,25 @@ def f(): local = 1 ''', '''\ - - + + + + f '''], ] totest['class'] = [ ['''\ class C: - """class C's docstring""" + """class C docstring""" ''', '''\ - - - - class C's docstring + + + + C + + class C docstring '''], ['''\ class C(Super): @@ -554,9 +730,22 @@ class D(SuperD, package.module.SuperD): pass ''', '''\ - - - + + + + C + + + Super + + + D + + + SuperD + + + package.module.SuperD '''], ['''\ class C: @@ -565,8 +754,10 @@ class C: """Not a docstring""" ''', '''\ - - + + + + C '''], ['''\ class C: @@ -575,11 +766,17 @@ class C: local = 1 ''', '''\ - - - - - + + + + C + + + f + + + + self '''], ['''\ class C: @@ -588,16 +785,26 @@ class C: local = 1 ''', '''\ - - - - - - - + + + + C + + + __init__ + + + + self + + + self.local + 1 - - + + + local + 1 '''], ['''\ @@ -606,13 +813,21 @@ class C: local = foo(a=1) ''', '''\ - - - - - - - + + + + C + + + __init__ + + + + self + + + local + foo(a=1) '''], ] @@ -622,13 +837,13 @@ totest['ignore'] = [ 1 + 2 ''', '''\ - + '''], ['''\ del a ''', '''\ - + '''], ] @@ -637,13 +852,13 @@ totest['comments'] = [ # # Comment # ''', # '''\ -# +# # # # Comment # '''], ] -# @@@ no comments yet +# @@@ we don't parse comments yet totest['everything'] = [ ['''\ # comment @@ -659,77 +874,106 @@ a = 1 class C(Super): - """C's docstring""" + """C docstring""" class_attribute = 1 - """class_attribute's docstring""" + """class_attribute docstring""" def __init__(self, text=None): - """__init__'s docstring""" + """__init__ docstring""" self.instance_attribute = (text * 7 + ' whaddyaknow') - """instance_attribute's docstring""" + """instance_attribute docstring""" def f(x, # parameter x y=a*5, # parameter y *args): # parameter args - """f's docstring""" + """f docstring""" return [x + item for item in args] f.function_attribute = 1 -"""f.function_attribute's docstring""" +"""f.function_attribute docstring""" ''', '''\ - - + + Docstring - + Additional docstring - - + + + __docformat__ + 'reStructuredText' - - + + + a + 1 - + Attribute docstring - - - C's docstring - - + + + C + + + Super + + C docstring + + + class_attribute + 1 - - class_attribute's docstring - - - __init__'s docstring - - - - + + class_attribute docstring + + + __init__ + + __init__ docstring + + + + self + + + text + None - - + + + self.instance_attribute + (text * 7 + ' whaddyaknow') - - instance_attribute's docstring - - - f's docstring - - - - + + instance_attribute docstring + + + f + + f docstring + + + + x + + + y + a * 5 - - - + + + args + + + f.function_attribute + 1 - - f.function_attribute's docstring + + f.function_attribute docstring '''], ] -- cgit v1.2.1 From 2a857c08d7ce28e3cd7b0f9731041fca0d15a254 Mon Sep 17 00:00:00 2001 From: wiemann Date: Tue, 22 Mar 2005 20:38:43 +0000 Subject: set executable bits on test files git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3085 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/test_functions.py | 0 test/test_readers/test_python/test_parser.py | 0 test/test_readers/test_python/test_token_parser.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/test_readers/test_python/test_functions.py mode change 100644 => 100755 test/test_readers/test_python/test_parser.py mode change 100644 => 100755 test/test_readers/test_python/test_token_parser.py (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/test_functions.py b/test/test_readers/test_python/test_functions.py old mode 100644 new mode 100755 diff --git a/test/test_readers/test_python/test_parser.py b/test/test_readers/test_python/test_parser.py old mode 100644 new mode 100755 diff --git a/test/test_readers/test_python/test_token_parser.py b/test/test_readers/test_python/test_token_parser.py old mode 100644 new mode 100755 -- cgit v1.2.1 From 0bb885fc5af28e2476186ce446ff991fe2f8438f Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 17 Jun 2005 22:24:13 +0000 Subject: fixed false assumption about path git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3509 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_readers/test_python/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/test_readers/test_python') diff --git a/test/test_readers/test_python/__init__.py b/test/test_readers/test_python/__init__.py index 2fe79c55c..46fc50e06 100644 --- a/test/test_readers/test_python/__init__.py +++ b/test/test_readers/test_python/__init__.py @@ -2,7 +2,7 @@ import os import os.path import sys -sys.path.insert(0, os.path.abspath(os.curdir)) +sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) prev = '' while sys.path[0] != prev: try: -- cgit v1.2.1