Skip to content

Commit

Permalink
Formally drop support for older versions of Django
Browse files Browse the repository at this point in the history
This removes declared support for versions below 1.11 and removes
related testing and functionality. This simplifies the definition of
the `EnumField` class as well as a number of tests.
  • Loading branch information
PeterJCLaw authored and lamby committed Sep 24, 2019
1 parent 670814e commit 29e0b41
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 29 deletions.
9 changes: 1 addition & 8 deletions django_enumfield/fields.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import six

from django import VERSION
from django.db import models

if VERSION < (1, 10):
metaclass = models.SubfieldBase
else:
metaclass = type

class EnumField(six.with_metaclass(metaclass, models.Field)):
class EnumField(models.Field):
def __init__(self, enum, *args, **kwargs):
self.enum = enum

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
packages=find_packages(),

install_requires=(
'Django>=1.8',
'Django>=1.11',
'six',
),
)
14 changes: 0 additions & 14 deletions tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import unittest

import django
from django.db import models
from django.db.utils import IntegrityError
from django.core import serializers
from django.http import HttpRequest, Http404
from django.test import TestCase as DjangoTestCase, override_settings
from django.template import RequestContext
from django.template.loader import render_to_string
from django.db.models.fields import NOT_PROVIDED
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -447,29 +445,17 @@ def test_isnull(self):

self.assertEqual(list(query), [m1])

def test_unsupported_lookup(self):
if django.VERSION < (1, 10):
# This feature is only supported pre-Django 1.10.
with self.assertRaises(TypeError):
TestModel.objects.filter(test_field__icontains=('blah',))


class TemplateTests(DjangoTestCase):
def test_renders_template(self):
kwargs = {'request': HttpRequest()}
if django.VERSION < (1, 10):
kwargs = {'context_instance': RequestContext(HttpRequest())}

self.assertEqual(
render_to_string('test.html', {}, **kwargs),
"Item A, Item B\n",
)

def test_fails_loudly_for_invalid_app(self):
kwargs = {'request': HttpRequest()}
if django.VERSION < (1, 10):
kwargs = {'context_instance': RequestContext(HttpRequest())}

with self.assertRaises(TemplateErrorException):
render_to_string('invalid.html', {}, **kwargs)

Expand Down
8 changes: 2 additions & 6 deletions tests/tests_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import tempfile
import subprocess

from django import VERSION
from django.test import TestCase as DjangoTestCase


Expand Down Expand Up @@ -66,10 +65,7 @@ def test_stable_migrations(self):
self.assertMigrationExists('0001')

self.run_command('migrate')

if VERSION < (1, 10):
self.run_command('makemigrations tests --exit', expect_failure=True)
else:
self.run_command('makemigrations tests --check', expect_failure=True)

self.run_command('makemigrations tests --check', expect_failure=True)

self.assertMigrationExists('0002', exists=False)

0 comments on commit 29e0b41

Please sign in to comment.