Running tests using an external process

Allow to run an external process to test your application

class webtest_casperjs.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_casperjs.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.done();
    this.test.renderResults(true);
});

The python part:

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