Fix compatibility with Django 3.0 alpha

Removed django.utils.six dependency, copied the parts we still need for
Python 2 compatibility.
This commit is contained in:
Diederik van der Boor
2019-07-12 17:38:49 +02:00
parent 7a315f7c17
commit 8fb8f47fb0
10 changed files with 71 additions and 26 deletions
+5 -4
View File
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
import django
import uuid
from django.contrib.contenttypes.models import ContentType
@@ -201,8 +201,9 @@ class MROBase3(models.Model):
class MRODerived(MROBase2, MROBase3):
class Meta:
manager_inheritance_from_future = True
if django.VERSION < (3, 0):
class Meta:
manager_inheritance_from_future = True
class ParentModelWithManager(PolymorphicModel):
@@ -477,4 +478,4 @@ class SubclassSelectorProxyModel(SubclassSelectorProxyBaseModel):
class SubclassSelectorProxyConcreteModel(SubclassSelectorProxyModel):
concrete_field = models.CharField(max_length=10, default='test_cf')
concrete_field = models.CharField(max_length=10, default='test_cf')
+2 -3
View File
@@ -5,9 +5,8 @@ from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models import Case, Count, Q, When
from django.test import TransactionTestCase
from django.utils import six
from polymorphic import query_translate
from polymorphic import compat, query_translate
from polymorphic.managers import PolymorphicManager
from polymorphic.models import PolymorphicTypeInvalid, PolymorphicTypeUndefined
from polymorphic.tests.models import (
@@ -566,7 +565,7 @@ class PolymorphicTests(TransactionTestCase):
select={"topic": "tests_modelextraexternal.topic"},
where=["tests_modelextraa.id = tests_modelextraexternal.id"],
)
if six.PY3:
if compat.PY3:
self.assertEqual(repr(objects[0]), '<ModelExtraA: id 1, field1 (CharField) "A1" - Extra: topic (str) "extra1">')
self.assertEqual(repr(objects[1]), '<ModelExtraB: id 2, field1 (CharField) "B1", field2 (CharField) "B2" - Extra: topic (str) "extra2">')
self.assertEqual(repr(objects[2]), '<ModelExtraC: id 3, field1 (CharField) "C1", field2 (CharField) "C2", field3 (CharField) "C3" - Extra: topic (str) "extra3">')