Search code examples
pythontornado

Tornado WSGI Unittest


I have an ongoing project in Google App Engine, and it uses Tornado as the web framework. That being said, I'm not sure how to do an Unittest with Tornado using WSGI mode. Can someone please give me some examples how should I write an unittest for Tornado using WSGI?


Solution

  • You can test this by ignoring either half of the equation:

    Tornado's WSGI mode doesn't allow any of the things that make regular Tornado apps tricky to test, so you can use App Engine's testing tools to test the app in the same way you would with any other WSGI framework (I don't know App Engine well enough to give you any pointers here)

    Or you can ignore the App Engine part and use Tornado's testing tools instead. You can test the Application before wrapping it in WSGIAdapter (if you're using WSGIApplication, I recommend switching to a regular tornado.web.Application and WSGIAdapter instead) using Tornado's AsyncHTTPTestCase