Simple collection of utilities that make testing Django with nose and twill easier and happier.


Plop this somewhere on your Python path.

Using Nose

To use Nose as your Django test runner, in

TEST_RUNNER = ‘django_satprep.nose_runner.run_tests’

This means that 'python test' will use Nose to collect/run tests.

Using Twill

If you're using Nose, you can easily write Twill tests. django_satprep gives you a quick setup you can use to talk to your Django project over wsgi.

Here's an example test:

from import * from twill import commands as twill

from django_satprep import twill_utils

@with_setup(test_utils.setup) def test_login():

"""Make sure a user can login from the home page.""" from django.contrib.auth import models user = models.User.objects.create(username='michael',

email='', password='bob', is_active=True) twill.go('twill_utils.TWILL_HOME) twill.code('200') twill.find('My Project') twill.find('Sign in') twill.follow('Sign in') twill.code('200') twill.fv('1', 'username', 'michael') twill.fv('1', 'password', 'bob') twill.submit() twill.code('200') twill.find('error') twill.find('michael') user.set_password('bob') twill.fv('1', 'password', 'bob') twill.submit() twill.code('200') twill.notfind('error')

Notice that twill is going to twill_utils.TWILL_HOME - by default, this is You can change the port by defining TWILL_WSGI_PORT in your