Skip to content

retresco/tornado_pyvows

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tornado_pyVows

This project contains extensions to test Tornado apps under pyVows.

TornadoHTTPContext

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.

TornadoContext

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")

Contributors

Contributions are very welcome. To contribute fork it and create a pull request.

The team behind Tornado_pyVows (in order of joining the project):

About

This project contains extensions to test Tornado apps under pyvows.

Resources

Stars

Watchers

Forks

Packages

No packages published