[py3] Fixed uses of __metaclass__ in tests.
This commit is contained in:
parent
450c0df653
commit
478a69314e
|
@ -22,8 +22,7 @@ class MyWrapper(object):
|
||||||
return self.value == other.value
|
return self.value == other.value
|
||||||
return self.value == other
|
return self.value == other
|
||||||
|
|
||||||
class MyAutoField(models.CharField):
|
class MyAutoField(six.with_metaclass(models.SubfieldBase, models.CharField)):
|
||||||
__metaclass__ = models.SubfieldBase
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs['max_length'] = 10
|
kwargs['max_length'] = 10
|
||||||
|
|
|
@ -20,13 +20,12 @@ class Small(object):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s%s' % (force_text(self.first), force_text(self.second))
|
return '%s%s' % (force_text(self.first), force_text(self.second))
|
||||||
|
|
||||||
class SmallField(models.Field):
|
class SmallField(six.with_metaclass(models.SubfieldBase, models.Field)):
|
||||||
"""
|
"""
|
||||||
Turns the "Small" class into a Django field. Because of the similarities
|
Turns the "Small" class into a Django field. Because of the similarities
|
||||||
with normal character fields and the fact that Small.__unicode__ does
|
with normal character fields and the fact that Small.__unicode__ does
|
||||||
something sensible, we don't need to implement a lot here.
|
something sensible, we don't need to implement a lot here.
|
||||||
"""
|
"""
|
||||||
__metaclass__ = models.SubfieldBase
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs['max_length'] = 2
|
kwargs['max_length'] = 2
|
||||||
|
@ -56,8 +55,7 @@ class SmallerField(SmallField):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class JSONField(models.TextField):
|
class JSONField(six.with_metaclass(models.SubfieldBase, models.TextField)):
|
||||||
__metaclass__ = models.SubfieldBase
|
|
||||||
|
|
||||||
description = ("JSONField automatically serializes and desializes values to "
|
description = ("JSONField automatically serializes and desializes values to "
|
||||||
"and from JSON.")
|
"and from JSON.")
|
||||||
|
|
|
@ -99,8 +99,7 @@ class Team(object):
|
||||||
return "%s" % self.title
|
return "%s" % self.title
|
||||||
|
|
||||||
|
|
||||||
class TeamField(models.CharField):
|
class TeamField(six.with_metaclass(models.SubfieldBase, models.CharField)):
|
||||||
__metaclass__ = models.SubfieldBase
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(TeamField, self).__init__(max_length=100)
|
super(TeamField, self).__init__(max_length=100)
|
||||||
|
|
|
@ -4,6 +4,7 @@ from functools import update_wrapper
|
||||||
|
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
|
from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
|
||||||
|
from django.utils import six
|
||||||
|
|
||||||
from .models import Reporter, Article
|
from .models import Reporter, Article
|
||||||
|
|
||||||
|
@ -35,8 +36,7 @@ class IgnoreNotimplementedError(type):
|
||||||
attrs[k] = ignore_not_implemented(v)
|
attrs[k] = ignore_not_implemented(v)
|
||||||
return type.__new__(cls, name, bases, attrs)
|
return type.__new__(cls, name, bases, attrs)
|
||||||
|
|
||||||
class IntrospectionTests(TestCase):
|
class IntrospectionTests(six.with_metaclass(IgnoreNotimplementedError, TestCase)):
|
||||||
__metaclass__ = IgnoreNotimplementedError
|
|
||||||
|
|
||||||
def test_table_names(self):
|
def test_table_names(self):
|
||||||
tl = connection.introspection.table_names()
|
tl = connection.introspection.table_names()
|
||||||
|
|
|
@ -485,9 +485,8 @@ class CustomMetaclass(ModelFormMetaclass):
|
||||||
new.base_fields = {}
|
new.base_fields = {}
|
||||||
return new
|
return new
|
||||||
|
|
||||||
class CustomMetaclassForm(forms.ModelForm):
|
class CustomMetaclassForm(six.with_metaclass(CustomMetaclass, forms.ModelForm)):
|
||||||
__metaclass__ = CustomMetaclass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CustomMetaclassTestCase(TestCase):
|
class CustomMetaclassTestCase(TestCase):
|
||||||
def test_modelform_factory_metaclass(self):
|
def test_modelform_factory_metaclass(self):
|
||||||
|
|
Loading…
Reference in New Issue