diff options
| author | goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2002-12-19 01:08:01 +0000 |
|---|---|---|
| committer | goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2002-12-19 01:08:01 +0000 |
| commit | 34762d707e5fbe502b302027e4318c8301d7a34d (patch) | |
| tree | 4b6ed584159b40d7cd9bc7ef78b90cc9874253fc /test/test_readers/test_python | |
| parent | f5260b063daae93f15562361988e5f3902d88625 (diff) | |
| download | docutils-34762d707e5fbe502b302027e4318c8301d7a34d.tar.gz | |
Added classes & methods.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1032 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'test/test_readers/test_python')
| -rw-r--r-- | test/test_readers/test_python/test_parser.py | 158 |
1 files changed, 158 insertions, 0 deletions
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""" +''', +'''\ +<Module filename="test data"> + <Class lineno="1" name="C"> + <Docstring lineno="1"> + class C's docstring +'''], +['''\ +class C(Super): + pass + +class D(SuperD, package.module.SuperD): + pass +''', +'''\ +<Module filename="test data"> + <Class bases="Super" lineno="1" name="C"> + <Class bases="SuperD package.module.SuperD" lineno="4" name="D"> +'''], +['''\ +class C: + class D: + pass + """Not a docstring""" +''', +'''\ +<Module filename="test data"> + <Class lineno="1" name="C"> +'''], +['''\ +class C: + def f(self): + self.local = 1 + local = 1 +''', +'''\ +<Module filename="test data"> + <Class lineno="1" name="C"> + <Method lineno="2" name="f"> + <ParameterList lineno="2"> + <Parameter lineno="2" name="self"> +'''], +['''\ +class C: + def __init__(self): + self.local = 1 + local = 1 +''', +'''\ +<Module filename="test data"> + <Class lineno="1" name="C"> + <Method lineno="2" name="__init__"> + <ParameterList lineno="2"> + <Parameter lineno="2" name="self"> + <Attribute lineno="3" name="self.local"> + <Expression lineno="3"> + 1 + <Attribute lineno="4" name="local"> + <Expression lineno="4"> + 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""" +''', +'''\ +<Module filename="test data"> + <Docstring> + Docstring + <Docstring lineno="5"> + Additional docstring + <Attribute lineno="7" name="__docformat__"> + <Expression lineno="7"> + 'reStructuredText' + <Attribute lineno="9" name="a"> + <Expression lineno="9"> + 1 + <Docstring lineno="10"> + Attribute docstring + <Class bases="Super" lineno="12" name="C"> + <Docstring lineno="12"> + C's docstring + <Attribute lineno="16" name="class_attribute"> + <Expression lineno="16"> + 1 + <Docstring lineno="17"> + class_attribute's docstring + <Method lineno="19" name="__init__"> + <Docstring lineno="19"> + __init__'s docstring + <ParameterList lineno="19"> + <Parameter lineno="19" name="self"> + <Parameter lineno="19" name="text"> + <Default lineno="19"> + None + <Attribute lineno="22" name="self.instance_attribute"> + <Expression lineno="22"> + (text * 7 + ' whaddyaknow') + <Docstring lineno="24"> + instance_attribute's docstring + <Function lineno="27" name="f"> + <Docstring lineno="27"> + f's docstring + <ParameterList lineno="27"> + <Parameter lineno="27" name="x"> + <Parameter lineno="27" name="y"> + <Default lineno="27"> + a * 5 + <ExcessPositionalArguments lineno="27" name="args"> + <Attribute lineno="33" name="f.function_attribute"> + <Expression lineno="33"> + 1 + <Docstring lineno="34"> + f.function_attribute's docstring +'''], +] + """ ['''\ ''', |
