Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[py3] Fixed uses of __metaclass__ in tests.

  • Loading branch information...
commit 478a69314e0f1a7fb4e9fd80f2cd3b9f210cc780 1 parent 450c0df
@aaugustin aaugustin authored
View
3  tests/modeltests/custom_pk/fields.py
@@ -22,8 +22,7 @@ def __eq__(self, other):
return self.value == other.value
return self.value == other
-class MyAutoField(models.CharField):
- __metaclass__ = models.SubfieldBase
+class MyAutoField(six.with_metaclass(models.SubfieldBase, models.CharField)):
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 10
View
6 tests/modeltests/field_subclassing/fields.py
@@ -20,13 +20,12 @@ def __init__(self, first, second):
def __str__(self):
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
with normal character fields and the fact that Small.__unicode__ does
something sensible, we don't need to implement a lot here.
"""
- __metaclass__ = models.SubfieldBase
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 2
@@ -56,8 +55,7 @@ class SmallerField(SmallField):
pass
-class JSONField(models.TextField):
- __metaclass__ = models.SubfieldBase
+class JSONField(six.with_metaclass(models.SubfieldBase, models.TextField)):
description = ("JSONField automatically serializes and desializes values to "
"and from JSON.")
View
3  tests/modeltests/serializers/models.py
@@ -99,8 +99,7 @@ def to_string(self):
return "%s" % self.title
-class TeamField(models.CharField):
- __metaclass__ = models.SubfieldBase
+class TeamField(six.with_metaclass(models.SubfieldBase, models.CharField)):
def __init__(self):
super(TeamField, self).__init__(max_length=100)
View
4 tests/regressiontests/introspection/tests.py
@@ -4,6 +4,7 @@
from django.db import connection
from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
+from django.utils import six
from .models import Reporter, Article
@@ -35,8 +36,7 @@ def __new__(cls, name, bases, attrs):
attrs[k] = ignore_not_implemented(v)
return type.__new__(cls, name, bases, attrs)
-class IntrospectionTests(TestCase):
- __metaclass__ = IgnoreNotimplementedError
+class IntrospectionTests(six.with_metaclass(IgnoreNotimplementedError, TestCase)):
def test_table_names(self):
tl = connection.introspection.table_names()
View
5 tests/regressiontests/model_forms_regress/tests.py
@@ -485,9 +485,8 @@ def __new__(cls, name, bases, attrs):
new.base_fields = {}
return new
-class CustomMetaclassForm(forms.ModelForm):
- __metaclass__ = CustomMetaclass
-
+class CustomMetaclassForm(six.with_metaclass(CustomMetaclass, forms.ModelForm)):
+ pass
class CustomMetaclassTestCase(TestCase):
def test_modelform_factory_metaclass(self):
Please sign in to comment.
Something went wrong with that request. Please try again.