Here is a great post for how to run Django tests headless. It uses xvfb.
Sometimes after a test crashes, the next time you run a test, you will get the error:
Traceback (most recent call last): File "/home/chuck/.virtualenvs/qdb7/local/lib/python2.7/site-packages/django/test/testcases.py", line 1189, in setUpClass raise cls.server_thread.error error: [Errno 98] Address already in use
To get rid of this error, find the Xvbf process that was left running after the crash:
ps aux | grep Xv
Then run kill on the pid.