4 from os.path import dirname, abspath
5 from optparse import OptionParser
7 from django.conf import settings, global_settings
9 # For convenience configure settings if they are not pre-configured or if we
10 # haven't been provided settings to use by environment variable.
11 if not settings.configured and not os.environ.get('DJANGO_SETTINGS_MODULE'):
14 'default': {'BACKEND':
15 'django.core.cache.backends.locmem.LocMemCache'},
17 'django.core.cache.backends.locmem.LocMemCache'},
21 'ENGINE': 'django.db.backends.sqlite3',
25 'django.contrib.auth',
26 'django.contrib.contenttypes',
27 'django.contrib.sessions',
28 'django.contrib.sites',
35 'ssify.middleware.SsiMiddleware',
36 'django.middleware.cache.UpdateCacheMiddleware',
37 'ssify.middleware.PrepareForCacheMiddleware',
38 'django.middleware.common.CommonMiddleware',
39 'django.middleware.cache.FetchFromCacheMiddleware',
41 STATIC_URL='/static/',
42 ROOT_URLCONF='tests.urls',
44 SSIFY_DEBUG_VERBOSE=False,
45 TEMPLATE_CONTEXT_PROCESSORS=(
46 "django.core.context_processors.debug",
47 "django.core.context_processors.i18n",
48 "django.core.context_processors.tz",
49 "django.core.context_processors.request",
53 from django.test.simple import DjangoTestSuiteRunner
56 def runtests(*test_args, **kwargs):
57 if 'south' in settings.INSTALLED_APPS:
58 from south.management.commands import patch_for_test_db_setup
59 patch_for_test_db_setup()
63 parent = dirname(abspath(__file__))
64 sys.path.insert(0, parent)
65 test_runner = DjangoTestSuiteRunner(
66 verbosity=kwargs.get('verbosity', 1),
67 interactive=kwargs.get('interactive', False),
68 failfast=kwargs.get('failfast'))
69 failures = test_runner.run_tests(test_args)
72 if __name__ == '__main__':
73 parser = OptionParser()
74 parser.add_option('--failfast', action='store_true',
75 default=False, dest='failfast')
77 (options, args) = parser.parse_args()
79 runtests(failfast=options.failfast, *args)