From bb13e463582fc22568a437d3ceeffe6598c9f0c6 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@1876 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- .../test/test_readers/test_python/test_parser.py | 778 ++++++++++++++------- 1 file changed, 511 insertions(+), 267 deletions(-) (limited to 'docutils/test/test_readers/test_python') diff --git a/docutils/test/test_readers/test_python/test_parser.py b/docutils/test/test_readers/test_python/test_parser.py index ce70cc27c..1ccfbdc10 100644 --- a/docutils/test/test_readers/test_python/test_parser.py +++ b/docutils/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