Provide new way to setup Django settings for tests

Instead of configuring Django settings within our code, we now provide a
test_settings module that can be used to run the test suite.
This commit is contained in:
Fabián Ezequiel Gallina 2014-04-30 16:43:37 -03:00
parent 04aac83d83
commit f87ccbca88
3 changed files with 21 additions and 21 deletions

View File

@ -1,27 +1,7 @@
from django.conf import settings
from django.utils.importlib import import_module
# Workaround for tests.
try:
minimal = {
'DATABASES': {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mydatabase'
}
},
'ROOT_URLCONF': '',
'STATSD_CLIENT': 'django_statsd.clients.null',
'STATSD_PREFIX': None,
'METLOG': None
}
if not settings.configured:
settings.configure(**minimal)
patches = getattr(settings, 'STATSD_PATCHES', [])
except ImportError:
patches = []
patches = getattr(settings, 'STATSD_PATCHES', [])
for patch in patches:
import_module(patch).patch()

View File

@ -0,0 +1,13 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mydatabase'
}
}
ROOT_URLCONF = ''
STATSD_CLIENT = 'django_statsd.clients.null'
STATSD_PREFIX = None,
METLOG = None
SECRET_KEY = 'secret'

View File

@ -308,6 +308,13 @@ do this by adding in the handler. For example in your logging configuration::
},
}
Testing
=======
You can run tests with the following command:
DJANGO_SETTINGS_MODULE='django_statsd.test_settings' nosetests
Nose
====