Fix: CHANGELOG.md in MANIFEST.in
[django-ssify.git] / runtests.py
index 8d27ecf..4fd6a9d 100644 (file)
@@ -1,10 +1,18 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
+# -*- coding: utf-8
+# This file is part of django-ssify, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See README.md for more information.
+#
+"""
+Creates a simple Django configuration and runs tests for django-ssify.
+"""
+from __future__ import unicode_literals
 import sys
 import os
 from os.path import dirname, abspath
 from optparse import OptionParser
 
 import sys
 import os
 from os.path import dirname, abspath
 from optparse import OptionParser
 
-from django.conf import settings, global_settings
+from django.conf import settings
 
 # For convenience configure settings if they are not pre-configured or if we
 # haven't been provided settings to use by environment variable.
 
 # For convenience configure settings if they are not pre-configured or if we
 # haven't been provided settings to use by environment variable.
@@ -30,18 +38,21 @@ if not settings.configured and not os.environ.get('DJANGO_SETTINGS_MODULE'):
             'ssify',
             'tests',
         ],
             'ssify',
             'tests',
         ],
+        LANGUAGE_CODE='pl',
         MEDIA_URL='/media/',
         MIDDLEWARE_CLASSES=[
         MEDIA_URL='/media/',
         MIDDLEWARE_CLASSES=[
+            'django.middleware.csrf.CsrfViewMiddleware',
             'ssify.middleware.SsiMiddleware',
             'django.middleware.cache.UpdateCacheMiddleware',
             'ssify.middleware.PrepareForCacheMiddleware',
             'django.middleware.common.CommonMiddleware',
             'ssify.middleware.SsiMiddleware',
             'django.middleware.cache.UpdateCacheMiddleware',
             'ssify.middleware.PrepareForCacheMiddleware',
             'django.middleware.common.CommonMiddleware',
+            'django.contrib.sessions.middleware.SessionMiddleware',
+            'ssify.middleware.LocaleMiddleware',
             'django.middleware.cache.FetchFromCacheMiddleware',
         ],
         STATIC_URL='/static/',
         ROOT_URLCONF='tests.urls',
         SITE_ID=1,
             'django.middleware.cache.FetchFromCacheMiddleware',
         ],
         STATIC_URL='/static/',
         ROOT_URLCONF='tests.urls',
         SITE_ID=1,
-        SSIFY_DEBUG_VERBOSE=False,
         TEMPLATE_CONTEXT_PROCESSORS=(
             "django.core.context_processors.debug",
             "django.core.context_processors.i18n",
         TEMPLATE_CONTEXT_PROCESSORS=(
             "django.core.context_processors.debug",
             "django.core.context_processors.i18n",
@@ -50,19 +61,29 @@ if not settings.configured and not os.environ.get('DJANGO_SETTINGS_MODULE'):
         ),
     )
 
         ),
     )
 
-from django.test.simple import DjangoTestSuiteRunner
+try:
+    from django.test.runner import DiscoverRunner
+except ImportError:
+    # Django < 1.6
+    from django.test.simple import DjangoTestSuiteRunner as DiscoverRunner
 
 
 def runtests(*test_args, **kwargs):
 
 
 def runtests(*test_args, **kwargs):
-    if 'south' in settings.INSTALLED_APPS:
-        from south.management.commands import patch_for_test_db_setup
-        patch_for_test_db_setup()
-
+    """Actual test suite entry point."""
     if not test_args:
         test_args = ['tests']
     parent = dirname(abspath(__file__))
     sys.path.insert(0, parent)
     if not test_args:
         test_args = ['tests']
     parent = dirname(abspath(__file__))
     sys.path.insert(0, parent)
-    test_runner = DjangoTestSuiteRunner(
+
+    # For Django 1.7+
+    try:
+        from django import setup
+    except ImportError:
+        pass
+    else:
+        setup()
+
+    test_runner = DiscoverRunner(
         verbosity=kwargs.get('verbosity', 1),
         interactive=kwargs.get('interactive', False),
         failfast=kwargs.get('failfast'))
         verbosity=kwargs.get('verbosity', 1),
         interactive=kwargs.get('interactive', False),
         failfast=kwargs.get('failfast'))