Fork me on GitHub

webtest.ext – Using an external process

Allow to run an external process to test your application

class webtest.ext.TestApp(app=None, url=None, timeout=30000, extra_environ=None, relative_to=None, **kwargs)[source]

Run the test application in a separate thread to allow to access it via http

close()[source]

Close WSGI server if needed

webtest.ext.casperjs(*args, **kwds)[source]

A context manager to run a test with a webtest.ext.TestApp

Using casperjs to run tests

The js part:

var system = require('system');
var url = system.env['APPLICATION_URL'];

var casper = require('casper').create();
casper.start(url, function() {
    this.test.assertTitle('It Works!');
});

casper.run(function() {
    this.test.renderResults(true);
});

The python part:

def test_casperjs():
    app = webtest.TestApp(application)
    with webtest.casperjs(app) as run:
        run('test_casperjs.js')

Table Of Contents

This Page