IIRC, web.py has a built-in browser that you can use for testing. A long time ago, I used it successfully to test an app in conjunction with nose. I don't remember the specifics, though, but the source code was very readable, last time I've looked at it.
On Fri, Jun 10, 2011 at 2:51 AM, Pete Emerson <[email protected]> wrote: > What are you using to unit test your web.py application? > > Following what I found on the web.py website, I started in with paste and > nose: > > http://webpy.org/cookbook/testing_with_paste_and_nose > > but as a Python newbie I'm struggling due to lack of great examples. > > For instance, my app returns a '400 Bad Request' under certain > circumstances, and so far I haven't been able to get the 400 code back > and also validate the response. By running my app and curling it, I > know that I'm producing a 400 Bad Request with some JSON text, but I > can't test it with paste / nose. > > This code: > > r = testApp.post('/auth', headers={'Content-Type':'text/plain'}, params=text) > assert_equal(r.status, 400) > > throws an exception (AppError: Bad response: 400 Bad Request (not 200 > OK or 3xx redirect for /auth)), and it looks like I should be > leveraging assert_raises from nose.tools, but I haven't been able to > find the golden code yet to solve this one. > > I'd be happy to show more code to try to fix this particular problem, > but it seems to me there might be other testing frameworks out there > that are full of good examples that might be a better fit for me. I'm > curious to hear what others are using to do their testing; the answer > may be that paste / nose is really the right tool, and I simply need > to be less of a Python newbie. If that's the case, so be it! > > Thanks, > Pete > > -- > You received this message because you are subscribed to the Google Groups > "web.py" 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/webpy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en.
