Debugging code when using Flask's TestClient

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging code when using Flask's TestClient

WingIDE - User mailing list
So, I have some code like this:

with app.test_client() as c:
    resp1=c.post('/login',data={'email':'[hidden email]','password':'somepassword'},follow_redirects=True)
    resp2 = c.get('/verify_email/%s' % verify_code)

Spaces removed so it won't wrap. :)

I am running the debugger over this.  I have enabled Debug Child Processes for
this project. I have a breakpoint set in the methods for /login and
/verify_email.  However, when they are called via the test_client, the
breakpoints are never triggered. I know the code is getting run, though,
because the c.post() and c.get() calls are returning information.

Is there a way to trigger breakpoints in called methods when using the
TestClient?

I could do a test_request_context, but then that means parsing headers
manually, extracting cookies, and all that fun stuff. :)

Thanks!

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com - Fairbanks, AK
PGP Key: http://pgp.mit.edu/  ID 0x73B13B6A
_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Debugging code when using Flask's TestClient

WingIDE - User mailing list
On 10/14/15 7:41 PM, Joshua J. Kugler via wingide-users wrote:
> I am running the debugger over this.  I have enabled Debug Child Processes for
> this project. I have a breakpoint set in the methods for /login and
> /verify_email.  However, when they are called via the test_client, the
> breakpoints are never triggered. I know the code is getting run, though,
> because the c.post() and c.get() calls are returning information.

What platform are you on? When I try on OS X, the program stops on a
breakpoint when I debug a simple unittest of an application that simply
returns 'Hello World!' for the root url.

Thanks,

John

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Debugging code when using Flask's TestClient

WingIDE - User mailing list
On Thursday, October 15, 2015 10:34:08 Wing IDE Support via wingide-users
wrote:

> On 10/14/15 7:41 PM, Joshua J. Kugler via wingide-users wrote:
> > I am running the debugger over this.  I have enabled Debug Child Processes
> > for this project. I have a breakpoint set in the methods for /login and
> > /verify_email.  However, when they are called via the test_client, the
> > breakpoints are never triggered. I know the code is getting run, though,
> > because the c.post() and c.get() calls are returning information.
>
> What platform are you on? When I try on OS X, the program stops on a
> breakpoint when I debug a simple unittest of an application that simply
> returns 'Hello World!' for the root url.

I am on Linux.  I just tried with a minimal test case, and the break points
worked both in the c.get() and c.post(). And now, trying again...it's working.  
I *KNOW* it wasn't working yesterday in my larger app.

Back to testing...sorry for the noise.

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com - Fairbanks, AK
PGP Key: http://pgp.mit.edu/  ID 0x73B13B6A
_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Debugging code when using Flask's TestClient

WingIDE - User mailing list
In reply to this post by WingIDE - User mailing list
On Thursday, October 15, 2015 10:34:08 Wing IDE Support via wingide-users
wrote:

> On 10/14/15 7:41 PM, Joshua J. Kugler via wingide-users wrote:
> > I am running the debugger over this.  I have enabled Debug Child Processes
> > for this project. I have a breakpoint set in the methods for /login and
> > /verify_email.  However, when they are called via the test_client, the
> > breakpoints are never triggered. I know the code is getting run, though,
> > because the c.post() and c.get() calls are returning information.
>
> What platform are you on? When I try on OS X, the program stops on a
> breakpoint when I debug a simple unittest of an application that simply
> returns 'Hello World!' for the root url.

Agghh! And now it's not working again. It works on the first function call (the
c.post), but goes right past the second function call (the c.get).

I have break points set in both places, and they are listed as active in the
breakpoints list.  This is weird.

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com - Fairbanks, AK
PGP Key: http://pgp.mit.edu/  ID 0x73B13B6A
_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Debugging code when using Flask's TestClient

WingIDE - User mailing list
In reply to this post by WingIDE - User mailing list
Not my day.

Appears a decorator on one of the views is issuing a redirect instead of
running the view code.

OK, off to debug other issues. Sorry again for the noise.

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com - Fairbanks, AK
PGP Key: http://pgp.mit.edu/  ID 0x73B13B6A
_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide