place the doctest for inner function in the docstring for innerfunction. now its called before the functions is defined...
On Mon, Jun 29, 2009 at 7:58 PM, Dan<[email protected]> wrote: > > I'd like to create some tests for functions that exist within a > controller using web2py's (very convenient) doctest integration. Is > this possible? > > For example, here is a controller with a subfunction and one test > defined for the controller and another defined for the function within > the controller: > > --- > def my_controller(): > """ > here are some doctests: > > >>> my_controller() > 35 > > >>> inner_function(1,2) > 3 > > """ > > def inner_function(a,b): > return a + b > > return 5 * inner_function(3,4) > --- > and when running tests, I get one error (edited for brevity): > > Line 7, ... in my_controller.__doc__ > Failed example: > inner_function(1,2) > Exception raised: > Traceback (most recent call last): > File "/usr/lib/python2.5/doctest.py", line 1228, in __run > compileflags, 1) in test.globs > File "... in my_controller.__doc__[1]>", line 1, in <module> > NameError: name 'inner_function' is not defined > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

