Skip to content

Instantly share code, notes, and snippets.

@lightstrike
Last active August 29, 2015 14:02
Show Gist options
  • Save lightstrike/85c6b40589c01c0b0c72 to your computer and use it in GitHub Desktop.
Save lightstrike/85c6b40589c01c0b0c72 to your computer and use it in GitHub Desktop.
Setting up Testing with Django-Nose, Coverage, Model Mommy and Selenium
1. Add following to requirements (recommend pip freeze after install and putting version numbers in file - ie coverage==3.7.1):
model_mommy
django-nose
coverage
selenium
2. Add Django Nose to INSTALLED APPS:
INSTALLED_APPS = (
...
'django_nose',
...
)
3. Define Django Nose test runner in settings:
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
4. Specify Django Nose run with coverage and which apps in INSTALLED_APPS to run tests:
# substitute app and account with the names of the apps you'd like tested
NOSE_ARGS = [
'--with-coverage',
'--cover-package=app,account',
]
5. If running South (django < 1.7), generally safest to disable migrations by putting this in settings (courtesy http://stackoverflow.com/questions/5798446/disable-django-south-when-running-unit-tests):
SOUTH_TESTS_MIGRATE = False
6. You're good to start testing with ./manage.py test to see coverage stats for the apps you've chosen :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment