mirror of
https://github.com/django/django.git
synced 2024-12-27 03:25:58 +00:00
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
from django.db import models
|
|
from django.test import SimpleTestCase
|
|
|
|
from .models import AutoModel, BigAutoModel, SmallAutoModel
|
|
from .test_integerfield import (
|
|
BigIntegerFieldTests,
|
|
IntegerFieldTests,
|
|
SmallIntegerFieldTests,
|
|
)
|
|
|
|
|
|
class AutoFieldTests(IntegerFieldTests):
|
|
model = AutoModel
|
|
rel_db_type_class = models.IntegerField
|
|
|
|
|
|
class BigAutoFieldTests(BigIntegerFieldTests):
|
|
model = BigAutoModel
|
|
rel_db_type_class = models.BigIntegerField
|
|
|
|
|
|
class SmallAutoFieldTests(SmallIntegerFieldTests):
|
|
model = SmallAutoModel
|
|
rel_db_type_class = models.SmallIntegerField
|
|
|
|
|
|
class AutoFieldInheritanceTests(SimpleTestCase):
|
|
def test_isinstance_of_autofield(self):
|
|
for field in (models.BigAutoField, models.SmallAutoField):
|
|
with self.subTest(field.__name__):
|
|
self.assertIsInstance(field(), models.AutoField)
|
|
|
|
def test_issubclass_of_autofield(self):
|
|
class MyBigAutoField(models.BigAutoField):
|
|
pass
|
|
|
|
class MySmallAutoField(models.SmallAutoField):
|
|
pass
|
|
|
|
tests = [
|
|
MyBigAutoField,
|
|
MySmallAutoField,
|
|
models.BigAutoField,
|
|
models.SmallAutoField,
|
|
]
|
|
for field in tests:
|
|
with self.subTest(field.__name__):
|
|
self.assertTrue(issubclass(field, models.AutoField))
|