mirror of
https://github.com/django/django.git
synced 2024-12-27 03:25:58 +00:00
[5.0.x] Isolated test models for GeneratedFields.
Test regression inf333e3513e
. Backport of8af3ae4ad9
from main
This commit is contained in:
parent
eeeacc52a9
commit
b5b361ab3b
@ -2,6 +2,7 @@ from django.db import IntegrityError, connection
|
|||||||
from django.db.models import F, FloatField, GeneratedField, IntegerField, Model
|
from django.db.models import F, FloatField, GeneratedField, IntegerField, Model
|
||||||
from django.db.models.functions import Lower
|
from django.db.models.functions import Lower
|
||||||
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
|
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
|
||||||
|
from django.test.utils import isolate_apps
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
GeneratedModel,
|
GeneratedModel,
|
||||||
@ -48,6 +49,7 @@ class BaseGeneratedFieldTests(SimpleTestCase):
|
|||||||
self.assertEqual(args, [])
|
self.assertEqual(args, [])
|
||||||
self.assertEqual(kwargs, {"db_persist": True, "expression": F("a") + F("b")})
|
self.assertEqual(kwargs, {"db_persist": True, "expression": F("a") + F("b")})
|
||||||
|
|
||||||
|
@isolate_apps("model_fields")
|
||||||
def test_get_col(self):
|
def test_get_col(self):
|
||||||
class Square(Model):
|
class Square(Model):
|
||||||
side = IntegerField()
|
side = IntegerField()
|
||||||
@ -67,6 +69,7 @@ class BaseGeneratedFieldTests(SimpleTestCase):
|
|||||||
col = FloatSquare._meta.get_field("area").get_col("alias")
|
col = FloatSquare._meta.get_field("area").get_col("alias")
|
||||||
self.assertIsInstance(col.output_field, FloatField)
|
self.assertIsInstance(col.output_field, FloatField)
|
||||||
|
|
||||||
|
@isolate_apps("model_fields")
|
||||||
def test_cached_col(self):
|
def test_cached_col(self):
|
||||||
class Sum(Model):
|
class Sum(Model):
|
||||||
a = IntegerField()
|
a = IntegerField()
|
||||||
|
Loading…
Reference in New Issue
Block a user