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:
parent
04aac83d83
commit
f87ccbca88
|
@ -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()
|
||||
|
|
|
@ -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'
|
|
@ -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
|
||||
====
|
||||
|
||||
|
|
Loading…
Reference in New Issue