Thursday, May 17, 2012

Starting Testing GAE Python App with Webtest

Recently I wanted to write automated tests for my GAE WSGI app (the app is written using web2py, but this detail may or may not be relevant to this post). Behavior-driven design, implemented by, e.g., Lettuce, seems to me as an ideal way to write tests---reasons seem to be well-described in this article by Scott Bellware. In python, Webtest is a good way to test WSGI apps. There are a couple of hurdles:

  • it seems that GAE app.yaml cannot be used to get a WSGI app needed to run Webtest-based tests. One get-around for this hurdle is to use WSGIProxy.
  • another (easier) problem is that Webtest redirects stdout and stderr streams, so the print function cannot be used for debugging. This problem can be circumvented using logging

No comments: