I managed to find a solution. After migrating to Django 1.4, I can use LiveServerTestCase and fork casperjs in the subprocess:
from django.test.testcases import LiveServerTestCase import os, subprocess from subprocess import Popen, PIPE, STDOUT class CasperTest(LiveServerTestCase): fixtures = ['test_initial_data', ] def test_my_testcase(self): p = Popen(['casperjs %s/caspertest.js' % os.path.dirname(__file__)], shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True) output = p.stdout.read() print output
source share