diff options
author | Rémi Duraffort <remi.duraffort@linaro.org> | 2016-08-08 16:32:13 +0200 |
---|---|---|
committer | Rémi Duraffort <remi.duraffort@linaro.org> | 2016-08-09 10:44:12 +0200 |
commit | 69d9802e792b830f73789f479e3162d1ced39835 (patch) | |
tree | 85d4da1627d41c765761781cbdde181bd62bd9e9 | |
parent | 6141bce20e6689250f68b2757e18204c82113949 (diff) |
Remove support for old Django version (<1.2)
Change-Id: I374caae4a6609bab3102aa1eb83420b5c2682f6a
-rw-r--r-- | django_testproject/settings.py | 28 | ||||
-rw-r--r-- | django_testproject/tests.py | 16 |
2 files changed, 11 insertions, 33 deletions
diff --git a/django_testproject/settings.py b/django_testproject/settings.py index 97be269..331873b 100644 --- a/django_testproject/settings.py +++ b/django_testproject/settings.py @@ -22,9 +22,6 @@ Settings generator for test projects import inspect import os -import sys - -import django DJANGO_TESTPROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -66,25 +63,12 @@ def _get_default_settings(project_dir): 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.transaction.TransactionMiddleware',) - if django.VERSION[0:2] >= (1, 2): - DATABASES = { - 'default': { - # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. - 'ENGINE': 'django.db.backends.sqlite3', - # Or path to database file if using sqlite3. - 'NAME': os.path.join(project_dir, 'test.db'), - 'USER': '', # Not used with sqlite3. - 'PASSWORD': '', # Not used with sqlite3. - 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. - 'PORT': '', # Set to empty string for default. Not used with sqlite3. - }} - else: - DATABASE_ENGINE = 'sqlite3' - DATABASE_NAME = os.path.join(project_dir, 'test.db') - DATABASE_USER = '' - DATABASE_PASSWORD = '' - DATABASE_HOST = '' - DATABASE_PORT = '' + DATABASE_ENGINE = 'sqlite3' + DATABASE_NAME = os.path.join(project_dir, 'test.db') + DATABASE_USER = '' + DATABASE_PASSWORD = '' + DATABASE_HOST = '' + DATABASE_PORT = '' return locals() diff --git a/django_testproject/tests.py b/django_testproject/tests.py index 6469800..13af8bc 100644 --- a/django_testproject/tests.py +++ b/django_testproject/tests.py @@ -23,7 +23,8 @@ Helper function for running tests via setup.py test import os import sys -import django +from django.conf import settings +from django.test.utils import get_runner def run_tests_for(settings_module_name, test_last_n_apps=-1): @@ -41,20 +42,13 @@ def run_tests_for(settings_module_name, test_last_n_apps=-1): """ os.environ['DJANGO_SETTINGS_MODULE'] = settings_module_name - from django.conf import settings - from django.test.utils import get_runner if test_last_n_apps is None: test_labels = None else: test_labels = settings.INSTALLED_APPS[test_last_n_apps:] - if django.VERSION[0:2] <= (1, 1): - # Prior to django 1.2 the runner was a plain function - runner_fn = get_runner(settings) - runner = lambda test_labels: runner_fn(test_labels, verbosity=2, interactive=False) - else: - # After 1.2 the runner is a class - runner_cls = get_runner(settings) - runner = runner_cls(verbosity=2, interactive=False).run_tests + + runner_cls = get_runner(settings) + runner = runner_cls(verbosity=2, interactive=False).run_tests failures = runner(test_labels) sys.exit(failures) |