Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
This project contains extensions to test Tornado apps under pyvows.
Branch: master
Pull request Compare This branch is 51 commits behind rafaelcaricio:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tornado_pyvows
vows
.gitignore
Makefile
README.mkd
setup.py

README.mkd

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

Something went wrong with that request. Please try again.