And just to clarify, that test passes if you remove the 
session.forget(response) line?

If so, could be a webclient.py bug -- please file a Github issue.

Anthony

On Monday, October 10, 2016 at 3:54:54 PM UTC-4, Mathieu Clabaut wrote:
>
> Hello Antony,
>
> The simplest failing test I run is the one from gluon/tests/test_web.py in 
> TestWeb.testRegisterAndLogin from commit 
> e6a3081b42ecd58441419930266baf286561c4c7.
>
> Where the default controller has only a line added to forget session and 
> reads :
>
> def index():
>     session.forget(response)   # Added line
>     response.flash = T("Hello World")
>     return dict(message=T('Welcome to web2py!'))
>
> The test is run with :
>
> python2 -m unittest -v gluon.tests.test_web.TestWeb.testRegisterAndLogin
>
> And outputs :
>
> ======================================================================
> FAIL: testRegisterAndLogin (gluon.tests.test_web.TestWeb)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "gluon/tests/test_web.py", line 92, in testRegisterAndLogin
>     self.assertTrue('Welcome Homer' in client.text)
> AssertionError: False is not true
>
> ----------------------------------------------------------------------
>
> Thank you very much for your time.
> ​
>
> On Mon, Oct 10, 2016 at 2:07 AM Anthony <[email protected]> wrote:
>
>>
>> I think the problem lies in `gluon/contrib/webclient.py` as the test 
>>> works well when using another browser like firefox.
>>> I just tried to call another action without `session.forget` before 
>>> calling `index`, but the test still failed after registration.
>>>
>>
>> Looking at the webclient.py code, it appears you can make a post request 
>> without any previous session -- it makes its own get request to set the 
>> CSRF token in the session.
>>
>> Anyway, it's not quite clear what you are doing. It may help to see the 
>> exact test you are running and how you are running it.
>>
>>
>> Anthony
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to