Drop old Python and Django versions (#220)
* drop old python and django versions * fix tests * remove compat module entirely Co-authored-by: Fabio Caccamo <fabio.caccamo@gmail.com>
This commit is contained in:
+6
-31
@@ -1,11 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
import django
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
SECRET_KEY = "django-admin-interface"
|
||||
@@ -18,17 +12,6 @@ INSTALLED_APPS = [
|
||||
"colorfield",
|
||||
]
|
||||
|
||||
if django.VERSION < (1, 9):
|
||||
# ONLY if django version < 1.9
|
||||
INSTALLED_APPS += [
|
||||
"flat",
|
||||
]
|
||||
|
||||
if django.VERSION < (2, 0):
|
||||
# ONLY if django version < 2.0
|
||||
INSTALLED_APPS += [
|
||||
"flat_responsive",
|
||||
]
|
||||
|
||||
INSTALLED_APPS += [
|
||||
"django.contrib.admin",
|
||||
@@ -38,20 +21,12 @@ INSTALLED_APPS += [
|
||||
"django.contrib.sessions",
|
||||
]
|
||||
|
||||
if django.VERSION < (2, 0):
|
||||
MIDDLEWARE_CLASSES = [
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
]
|
||||
else:
|
||||
MIDDLEWARE = [
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
]
|
||||
MIDDLEWARE = [
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
]
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import random
|
||||
import shutil
|
||||
from unittest import expectedFailure
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from unittest import skipIf
|
||||
|
||||
from django import VERSION
|
||||
from django.test import TestCase
|
||||
|
||||
from admin_interface.models import Theme
|
||||
@@ -24,9 +23,6 @@ class AdminInterfaceModelsWithDBRoutingTestCase(TestCase):
|
||||
db_for_theme = router.db_for_read(Theme)
|
||||
assert db_for_theme == "replica"
|
||||
|
||||
@skipIf(
|
||||
VERSION[0] < 2, "TestCase does not respect database param on older versions"
|
||||
)
|
||||
def test_dbrouter_errors_when_fetching_from_default(self):
|
||||
with self.assertRaises(Exception):
|
||||
Theme.get_active_theme()
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.test import TestCase, override_settings
|
||||
@@ -27,24 +22,10 @@ class AdminInterfaceSettingsTestCase(TestCase):
|
||||
pass
|
||||
|
||||
def __test_installed_apps(self):
|
||||
dj_version = django.VERSION
|
||||
installed_apps = settings.INSTALLED_APPS
|
||||
|
||||
if "colorfield" not in installed_apps:
|
||||
self.assertRaises(ImproperlyConfigured, check_installed_apps)
|
||||
|
||||
elif "flat" not in installed_apps and dj_version < (1, 9):
|
||||
self.assertRaises(ImproperlyConfigured, check_installed_apps)
|
||||
|
||||
elif "flat" in installed_apps and dj_version >= (1, 9):
|
||||
self.assertRaises(ImproperlyConfigured, check_installed_apps)
|
||||
|
||||
elif "flat_responsive" not in installed_apps and dj_version < (2, 0):
|
||||
self.assertRaises(ImproperlyConfigured, check_installed_apps)
|
||||
|
||||
elif "flat_responsive" in installed_apps and dj_version >= (2, 0):
|
||||
self.assertRaises(ImproperlyConfigured, check_installed_apps)
|
||||
|
||||
else:
|
||||
check_installed_apps()
|
||||
|
||||
@@ -52,8 +33,6 @@ class AdminInterfaceSettingsTestCase(TestCase):
|
||||
INSTALLED_APPS=[
|
||||
"admin_interface",
|
||||
"colorfield",
|
||||
"flat",
|
||||
"flat_responsive",
|
||||
]
|
||||
+ DJANGO_APPS
|
||||
)
|
||||
@@ -64,34 +43,8 @@ class AdminInterfaceSettingsTestCase(TestCase):
|
||||
INSTALLED_APPS=[
|
||||
"admin_interface",
|
||||
# 'colorfield',
|
||||
"flat",
|
||||
"flat_responsive",
|
||||
]
|
||||
+ DJANGO_APPS
|
||||
)
|
||||
def test_installed_apps_no_colorfield(self):
|
||||
self.__test_installed_apps()
|
||||
|
||||
@override_settings(
|
||||
INSTALLED_APPS=[
|
||||
"admin_interface",
|
||||
"colorfield",
|
||||
# 'flat',
|
||||
"flat_responsive",
|
||||
]
|
||||
+ DJANGO_APPS
|
||||
)
|
||||
def test_installed_apps_no_flat(self):
|
||||
self.__test_installed_apps()
|
||||
|
||||
@override_settings(
|
||||
INSTALLED_APPS=[
|
||||
"admin_interface",
|
||||
"colorfield",
|
||||
"flat",
|
||||
# 'flat_responsive',
|
||||
]
|
||||
+ DJANGO_APPS
|
||||
)
|
||||
def test_installed_apps_no_flat_responsive(self):
|
||||
self.__test_installed_apps()
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.template import Context, Template
|
||||
from django.test import TestCase, override_settings
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
+4
-15
@@ -1,22 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django
|
||||
from django.contrib import admin
|
||||
|
||||
if django.VERSION < (2, 0):
|
||||
from django.conf.urls import include
|
||||
from django.conf.urls import url as re_path
|
||||
else:
|
||||
from django.urls import include, re_path
|
||||
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
|
||||
urlpatterns = []
|
||||
urlpatterns += [
|
||||
re_path(r"^i18n/", include("django.conf.urls.i18n")),
|
||||
path("i18n/", include("django.conf.urls.i18n")),
|
||||
]
|
||||
urlpatterns += i18n_patterns(
|
||||
re_path(r"^admin/", admin.site.urls),
|
||||
path("admin/", admin.site.urls),
|
||||
)
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django
|
||||
from django.contrib import admin
|
||||
|
||||
if django.VERSION < (2, 0):
|
||||
from django.conf.urls import url as re_path
|
||||
else:
|
||||
from django.urls import re_path
|
||||
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
re_path(r"^admin/", admin.site.urls),
|
||||
path("admin/", admin.site.urls),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user