On Oct 16, 4:32 am, rboissat <[email protected]> wrote:
> Hi,
>
> I'm using web2py v1.66.2 and I have some issues to run doctest within
> the admin app.
>
> Indeed, when a function in a controller is decorated, let's say with
> @auth.requires_login(),
> then the tests from doctests are not running and are marked as "[no
> doctest]".
Yes this is a known bug. I do not have a solution. Any idea?
> I assume this is due to the lack of a running environment while
> running the test.
>
> If not decorated, test are running fine. Test are somewhat basic, like>>>
> index().has_key('form')
>
> True
>
> So, how could I instantiate a dummy environment,
yes:
from gluon.globals import Request, Response, Session
from gluon.compileapp import build_environment
env = build_environment(Request(),Response(),Session())
> or maybe simpler, have a conditional decorator
> ( if request.application != "admin", then decorate the function, else
> leave undecorated), since my tests
> are basic and do not require an auth user to call the function.
Yes, you can do this. In controller instead of
@auth.requires_login()
def index(): return dict()
you can do
def index(): return dict()
if (condition):
index=auth.requires_login()(index)
> Thanks for any thoughts about this :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" 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
-~----------~----~----~----~------~----~------~--~---