Skip to content

Commit

Permalink
Drop unsupported django versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan P Kilby committed Jan 12, 2017
1 parent 625e104 commit fda2d39
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 199 deletions.
18 changes: 3 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,18 @@ language: python
python: 2.7

env:
- TOXENV=py26-django14
- TOXENV=py26-django15
- TOXENV=py26-django16
- TOXENV=py27-django110
- TOXENV=py27-django14
- TOXENV=py27-django15
- TOXENV=py27-django15_nosouth
- TOXENV=py27-django16
- TOXENV=py27-django17
- TOXENV=py27-django18
- TOXENV=py27-django19
- TOXENV=py27-django110
- TOXENV=py27-django_trunk
- TOXENV=py33-django15
- TOXENV=py33-django16
- TOXENV=py33-django17
- TOXENV=py33-django18
- TOXENV=py34-django110
- TOXENV=py34-django17
- TOXENV=py34-django18
- TOXENV=py34-django19
- TOXENV=py34-django110
- TOXENV=py34-django_trunk
- TOXENV=py35-django110
- TOXENV=py35-django18
- TOXENV=py35-django19
- TOXENV=py35-django110
- TOXENV=py35-django_trunk

install:
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ CHANGES
master (unreleased)
-------------------

* Drop support for Python 2.6.

* Drop support for Django 1.4, 1.5, 1.6, 1.7.


2.6.1 (2017.01.11)
------------------

Expand Down
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ django-model-utils

Django model mixins and utilities.

``django-model-utils`` supports `Django`_ 1.4 through 1.9 (latest bugfix
release in each series only) on Python 2.6 (through Django 1.6 only), 2.7, 3.3
(through Django 1.8 only), 3.4 and 3.5.
``django-model-utils`` supports `Django`_ 1.8 through 1.10 (latest bugfix
release in each series only) on Python 2.7, 3.3 (Django 1.8 only), 3.4 and 3.5.

.. _Django: http://www.djangoproject.com/

Expand Down
27 changes: 0 additions & 27 deletions model_utils/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,30 +241,3 @@ def deconstruct(self):
name, path, args, kwargs = super(SplitField, self).deconstruct()
kwargs['no_excerpt_field'] = True
return name, path, args, kwargs

# allow South to handle these fields smoothly
try:
from south.modelsinspector import add_introspection_rules
# For a normal MarkupField, the add_excerpt_field attribute is
# always True, which means no_excerpt_field arg will always be
# True in a frozen MarkupField, which is what we want.
add_introspection_rules(rules=[
(
(SplitField,),
[],
{'no_excerpt_field': ('add_excerpt_field', {})}
),
(
(MonitorField,),
[],
{'monitor': ('monitor', {})}
),
(
(StatusField,),
[],
{'no_check_for_status': ('check_for_status', {})}
),
], patterns=['model_utils\.fields\.'])
except ImportError:
pass

8 changes: 2 additions & 6 deletions model_utils/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
from django.db.models.query import QuerySet
from django.core.exceptions import ObjectDoesNotExist

try:
from django.db.models.constants import LOOKUP_SEP
from django.utils.six import string_types
except ImportError: # Django < 1.5
from django.db.models.sql.constants import LOOKUP_SEP
string_types = (basestring,)
from django.db.models.constants import LOOKUP_SEP
from django.utils.six import string_types


class InheritanceQuerySetMixin(object):
Expand Down
5 changes: 0 additions & 5 deletions model_utils/tests/helpers.py

This file was deleted.

5 changes: 0 additions & 5 deletions model_utils/tests/test_fields/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
# Needed for Django 1.4/1.5 test runner
from .test_field_tracker import *
from .test_monitor_field import *
from .test_split_field import *
from .test_status_field import *
41 changes: 18 additions & 23 deletions model_utils/tests/test_fields/test_field_tracker.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import unicode_literals

from unittest import skipUnless

import django
from django.core.exceptions import FieldError
from django.test import TestCase

from model_utils import FieldTracker
from model_utils.tests.helpers import skipUnless
from model_utils.tests.models import (
Tracked, TrackedFK, InheritedTrackedFK, TrackedNotDefault, TrackedNonFieldAttr, TrackedMultiple,
InheritedTracked, TrackedFileField,
Expand Down Expand Up @@ -97,15 +98,14 @@ def test_first_save(self):
self.assertPrevious(name=None, number=None, mutable=None)
self.assertCurrent(name='retro', number=4, id=None, mutable=[1,2,3])
self.assertChanged(name=None, number=None, mutable=None)
# Django 1.4 doesn't have update_fields
if django.VERSION >= (1, 5, 0):
self.instance.save(update_fields=[])
self.assertHasChanged(name=True, number=True, mutable=True)
self.assertPrevious(name=None, number=None, mutable=None)
self.assertCurrent(name='retro', number=4, id=None, mutable=[1,2,3])
self.assertChanged(name=None, number=None, mutable=None)
with self.assertRaises(ValueError):
self.instance.save(update_fields=['number'])

self.instance.save(update_fields=[])
self.assertHasChanged(name=True, number=True, mutable=True)
self.assertPrevious(name=None, number=None, mutable=None)
self.assertCurrent(name='retro', number=4, id=None, mutable=[1,2,3])
self.assertChanged(name=None, number=None, mutable=None)
with self.assertRaises(ValueError):
self.instance.save(update_fields=['number'])

def test_post_save_has_changed(self):
self.update_instance(name='retro', number=4, mutable=[1,2,3])
Expand Down Expand Up @@ -153,8 +153,6 @@ def test_current(self):
self.instance.save()
self.assertCurrent(id=self.instance.id, name='new age', number=8, mutable=[1,4,3])

@skipUnless(
django.VERSION >= (1, 5, 0), "Django 1.4 doesn't have update_fields")
def test_update_fields(self):
self.update_instance(name='retro', number=4, mutable=[1,2,3])
self.assertChanged()
Expand Down Expand Up @@ -280,8 +278,6 @@ def test_current(self):
self.instance.save()
self.assertCurrent(name='new age')

@skipUnless(
django.VERSION >= (1, 5, 0), "Django 1.4 doesn't have update_fields")
def test_update_fields(self):
self.update_instance(name='retro', number=4)
self.assertChanged()
Expand Down Expand Up @@ -622,15 +618,14 @@ def test_first_save(self):
self.assertPrevious(name=None, number=None, mutable=None)
self.assertCurrent(name='retro', number=4, id=None, mutable=[1,2,3])
self.assertChanged()
# Django 1.4 doesn't have update_fields
if django.VERSION >= (1, 5, 0):
self.instance.save(update_fields=[])
self.assertHasChanged(name=True, number=True, mutable=True)
self.assertPrevious(name=None, number=None, mutable=None)
self.assertCurrent(name='retro', number=4, id=None, mutable=[1,2,3])
self.assertChanged()
with self.assertRaises(ValueError):
self.instance.save(update_fields=['number'])

self.instance.save(update_fields=[])
self.assertHasChanged(name=True, number=True, mutable=True)
self.assertPrevious(name=None, number=None, mutable=None)
self.assertCurrent(name='retro', number=4, id=None, mutable=[1,2,3])
self.assertChanged()
with self.assertRaises(ValueError):
self.instance.save(update_fields=['number'])

def test_pre_save_has_changed(self):
self.assertHasChanged(name=True, number=True)
Expand Down
5 changes: 0 additions & 5 deletions model_utils/tests/test_managers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
# Needed for Django 1.4/1.5 test runner
from .test_inheritance_manager import *
from .test_query_manager import *
from .test_status_manager import *
from .test_softdelete_manager import *
62 changes: 9 additions & 53 deletions model_utils/tests/test_managers/test_inheritance_manager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import unicode_literals

from unittest import skipUnless

import django
from django.db import models
from django.test import TestCase

from model_utils.tests.helpers import skipUnless
from model_utils.tests.models import (InheritanceManagerTestRelated, InheritanceManagerTestGrandChild1,
InheritanceManagerTestGrandChild1_2, InheritanceManagerTestParent,
InheritanceManagerTestChild1,
Expand Down Expand Up @@ -34,12 +35,8 @@ def test_normal(self):

def test_select_all_subclasses(self):
children = set([self.child1, self.child2])
if django.VERSION >= (1, 6, 0):
children.add(self.grandchild1)
children.add(self.grandchild1_2)
else:
children.add(InheritanceManagerTestChild1(pk=self.grandchild1.pk))
children.add(InheritanceManagerTestChild1(pk=self.grandchild1_2.pk))
children.add(self.grandchild1)
children.add(self.grandchild1_2)
self.assertEqual(
set(self.get_manager().select_subclasses()), children)

Expand Down Expand Up @@ -68,7 +65,6 @@ def test_select_specific_subclasses(self):
children,
)

@skipUnless(django.VERSION >= (1, 6, 0), "test only applies to Django 1.6+")
def test_select_specific_grandchildren(self):
children = set([
InheritanceManagerTestParent(pk=self.child1.pk),
Expand All @@ -85,7 +81,6 @@ def test_select_specific_grandchildren(self):
children,
)

@skipUnless(django.VERSION >= (1, 6, 0), "test only applies to Django 1.6+")
def test_children_and_grandchildren(self):
children = set([
self.child1,
Expand Down Expand Up @@ -120,39 +115,9 @@ def test_prior_select_related(self):
"inheritancemanagertestchild2").get(pk=self.child1.pk)
obj.inheritancemanagertestchild1

@skipUnless(django.VERSION >= (1, 6, 0), "test only applies to Django 1.6+")
def test_version_determining_any_depth(self):
self.assertIsNone(self.get_manager().all()._get_maximum_depth())

@skipUnless(django.VERSION < (1, 6, 0), "test only applies to Django < 1.6")
def test_version_determining_only_child_depth(self):
self.assertEqual(1, self.get_manager().all()._get_maximum_depth())

@skipUnless(django.VERSION < (1, 6, 0), "test only applies to Django < 1.6")
def test_manually_specifying_parent_fk_only_children(self):
"""
given a Model which inherits from another Model, but also declares
the OneToOne link manually using `related_name` and `parent_link`,
ensure that the relation names and subclasses are obtained correctly.
"""
child3 = InheritanceManagerTestChild3.objects.create()
results = InheritanceManagerTestParent.objects.all().select_subclasses()

expected_objs = [self.child1, self.child2,
InheritanceManagerTestChild1(pk=self.grandchild1.pk),
InheritanceManagerTestChild1(pk=self.grandchild1_2.pk),
child3]
self.assertEqual(list(results), expected_objs)

expected_related_names = [
'inheritancemanagertestchild1',
'inheritancemanagertestchild2',
'manual_onetoone', # this was set via parent_link & related_name
]
self.assertEqual(set(results.subclasses),
set(expected_related_names))

@skipUnless(django.VERSION >= (1, 6, 0), "test only applies to Django 1.6+")
def test_manually_specifying_parent_fk_including_grandchildren(self):
"""
given a Model which inherits from another Model, but also declares
Expand Down Expand Up @@ -267,7 +232,6 @@ def test_select_subclass_by_child_model(self):
self.assertEqual(objs.subclasses, objsmodels.subclasses)
self.assertEqual(list(objs), list(objsmodels))

@skipUnless(django.VERSION >= (1, 6, 0), "test only applies to Django 1.6+")
def test_select_subclass_by_grandchild_model(self):
"""
Confirm that passing a grandchild model works the same as passing the
Expand All @@ -281,7 +245,6 @@ def test_select_subclass_by_grandchild_model(self):
self.assertEqual(objs.subclasses, objsmodels.subclasses)
self.assertEqual(list(objs), list(objsmodels))

@skipUnless(django.VERSION >= (1, 6, 0), "test only applies to Django 1.6+")
def test_selecting_all_subclasses_specifically_grandchildren(self):
"""
A bare select_subclasses() should achieve the same results as doing
Expand Down Expand Up @@ -310,16 +273,11 @@ def test_selecting_all_subclasses_specifically_children(self):
"""
objs = InheritanceManagerTestParent.objects.select_subclasses().order_by('pk')

if django.VERSION >= (1, 6, 0):
models = (InheritanceManagerTestChild1,
InheritanceManagerTestChild2,
InheritanceManagerTestChild3,
InheritanceManagerTestGrandChild1,
InheritanceManagerTestGrandChild1_2)
else:
models = (InheritanceManagerTestChild1,
InheritanceManagerTestChild2,
InheritanceManagerTestChild3)
models = (InheritanceManagerTestChild1,
InheritanceManagerTestChild2,
InheritanceManagerTestChild3,
InheritanceManagerTestGrandChild1,
InheritanceManagerTestGrandChild1_2)

objsmodels = InheritanceManagerTestParent.objects.select_subclasses(
*models).order_by('pk')
Expand Down Expand Up @@ -353,7 +311,6 @@ def test_select_subclass_invalid_related_model(self):
InheritanceManagerTestParent.objects.select_subclasses(
TimeFrame).order_by('pk')

@skipUnless(django.VERSION >= (1, 6, 0), "test only applies to Django 1.6+")
def test_mixing_strings_and_classes_with_grandchildren(self):
"""
Given arguments consisting of both strings and model classes,
Expand Down Expand Up @@ -414,7 +371,6 @@ def test_duplications(self):
InheritanceManagerTestParent(pk=self.grandchild1_2.pk),
])

@skipUnless(django.VERSION >= (1, 6, 0), "test only applies to Django 1.6+")
def test_child_doesnt_accidentally_get_parent(self):
"""
Given a Child model which also has an InheritanceManager,
Expand Down
31 changes: 0 additions & 31 deletions model_utils/tests/test_miscellaneous.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
from __future__ import unicode_literals

import django
from django.db.models.fields import FieldDoesNotExist
from django.core.management import call_command
from django.test import TestCase

from model_utils.fields import get_excerpt
from model_utils.tests.models import (
Article,
StatusFieldDefaultFilled,
)
from model_utils.tests.helpers import skipUnless


class MigrationsTests(TestCase):
@skipUnless(django.VERSION >= (1, 7, 0), "test only applies to Django 1.7+")
def test_makemigrations(self):
call_command('makemigrations', dry_run=True)

Expand All @@ -35,26 +27,3 @@ def test_middle_of_para(self):
def test_middle_of_line(self):
e = get_excerpt("some text <!-- split --> more text")
self.assertEqual(e, "some text <!-- split --> more text")

try:
from south.modelsinspector import introspector
except ImportError:
introspector = None


@skipUnless(introspector, 'South is not installed')
class SouthFreezingTests(TestCase):
def test_introspector_adds_no_excerpt_field(self):
mf = Article._meta.get_field('body')
args, kwargs = introspector(mf)
self.assertEqual(kwargs['no_excerpt_field'], 'True')

def test_no_excerpt_field_works(self):
from .models import NoRendered
with self.assertRaises(FieldDoesNotExist):
NoRendered._meta.get_field('_body_excerpt')

def test_status_field_no_check_for_status(self):
sf = StatusFieldDefaultFilled._meta.get_field('status')
args, kwargs = introspector(sf)
self.assertEqual(kwargs['no_check_for_status'], 'True')
5 changes: 0 additions & 5 deletions model_utils/tests/test_models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
# Needed for Django 1.4/1.5 test runner
from .test_softdeletable_model import *
from .test_status_model import *
from .test_timeframed_model import *
from .test_timestamped_model import *
Loading

0 comments on commit fda2d39

Please sign in to comment.