This project contains extensions to test Tornado apps under pyVows.
To test a tornado app (or handlers) use this context instead of the regular Vows.Context, like this:
@Vows.batch
class SomeVows(TornadoHTTPContext):
def _get_app(self):
application = tornado.web.Application([
(r"/", HomeHandler),
])
return application
class HomeUrl(TornadoHTTPContext):
def topic(self):
self._http_client.fetch(self._get_url('/'), self._stop)
response = self._wait()
return response.body
def should_be_hello_world(self, topic):
expect(topic).to_equal('hello_world')
Each TornadoHTTPContext
provides Tornado's testing methods like
_http_client
, _get_url
, _stop
, _wait
, _fetch
and others.
If you want to test a tornado based app without the HTTP overhead you may also
use the TornadoContext
:
def asyncMethod(callback):
callback("Pseudo Async Result")
@Vows.batch
class AsyncVows(TornadoContext):
class CallbacksShouldWork(TornadoContext):
def topic(self):
self.io_loop.add_callback(partial(asyncMethod, self._stop))
return self._wait()
def andHaveTheCorrectResult(self, topic):
expect(topic).to_equal("Pseudo Async Result")
Contributions are very welcome. To contribute fork it and create a pull request.
The team behind Tornado_pyVows (in order of joining the project):
- Rafael Carício @rafaelcaricio
- Bernardo Heynemann @heynemann
- Daniel Truemper @truemperd