Skip to content

Instantly share code, notes, and snippets.

@turtlemonvh
Created July 25, 2013 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turtlemonvh/6083533 to your computer and use it in GitHub Desktop.
Save turtlemonvh/6083533 to your computer and use it in GitHub Desktop.
A nose specific settings file. Specify this for running tests using the nose test framework. Allows you to run tests using the normal Django test library the usual way. Requires the `nose` and `django-nose` python packages. This version also creates xml coverage and test reports in cobertura and xunit format, respectively.
"""
Specify this settings file to run nose tests format instead of the standard Django test runner.
Useful for getting coverage reports and for getting xunit compaible reports for use with a CI server.
To run all tests:
> python manage.py test --settings=settings_folder.nose_settings apps
To run tests only for a specific app:
> python manage.py test --settings=settings_folder.nose_settings apps.myapp.tests
"""
try:
from settings import *
except ImportError:
pass
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
'--testmatch=^test',
'--with-xunit',
'--xunit-file=xmlrunner/nosetests.xml',
'--with-coverage',
'--cover-xml',
'--cover-package=apps.myapp,apps.mysecondapp', # a list of packages to get coverage data for
'--cover-xml-file=xmlrunner/coverage.xml'
]
# Create directory for xml files
if not os.path.exists("xmlrunner"):
os.makedirs("xmlrunner")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment