[py-svn] r34592 - in py/dist/py/apigen: rest rest/testing tracer
fijal at codespeak.net
fijal at codespeak.net
Tue Nov 14 10:58:03 CET 2006
Author: fijal
Date: Tue Nov 14 10:58:01 2006
New Revision: 34592
Modified:
py/dist/py/apigen/rest/genrest.py
py/dist/py/apigen/rest/testing/test_rest.py
py/dist/py/apigen/tracer/docstorage.py
Log:
Added generation of exception info into rest.
Modified: py/dist/py/apigen/rest/genrest.py
==============================================================================
--- py/dist/py/apigen/rest/genrest.py (original)
+++ py/dist/py/apigen/rest/genrest.py Tue Nov 14 10:58:01 2006
@@ -335,6 +335,11 @@
for k, changeset in local_changes.iteritems():
lst.append(ListItem('%s: %s' % (k, ', '.join(changeset))))
+ lst.append(Paragraph('Exceptions that might appear in function body:'))
+ for exc in self.dsa.get_function_exceptions(functionname):
+ lst.append(ListItem(exc.__name__))
+ # XXX: right now we leave it alone
+
# XXX missing implementation of dsa.get_function_location()
#filename, lineno = self.dsa.get_function_location(functionname)
#linkname, linktarget = self.linkgen.getlink(filename, lineno)
Modified: py/dist/py/apigen/rest/testing/test_rest.py
==============================================================================
--- py/dist/py/apigen/rest/testing/test_rest.py (original)
+++ py/dist/py/apigen/rest/testing/test_rest.py Tue Nov 14 10:58:01 2006
@@ -346,3 +346,23 @@
assert call_point != -1
assert source.find("x \:\: <Instance of AnyOf( `Class B`_ , `Class A`_ )>") < call_point
self.check_rest(tempdir)
+
+ def test_exc_raising(self):
+ def x():
+ try:
+ 1/0
+ except:
+ pass
+
+ descs = {'x':x}
+ ds = DocStorage().from_dict(descs)
+ t = Tracer(ds)
+ t.start_tracing()
+ x()
+ t.end_tracing()
+ lg = DirectPaste()
+ tempdir = temppath.ensure("exc_raising", dir=True)
+ r = RestGen(ds, lg, DirWriter(tempdir))
+ r.write()
+ source = tempdir.join('function_x.txt').open().read()
+ assert source.find('ZeroDivisionError') < source.find('Call sites\:')
Modified: py/dist/py/apigen/tracer/docstorage.py
==============================================================================
--- py/dist/py/apigen/tracer/docstorage.py (original)
+++ py/dist/py/apigen/tracer/docstorage.py Tue Nov 14 10:58:01 2006
@@ -251,3 +251,6 @@
except AttributeError:
pass
return retval
+
+ def get_function_exceptions(self, name):
+ return sorted(self.ds.descs[name].exceptions.keys())
More information about the py-svn
mailing list