Fixed #30095 -- Fixed system check for RangeField/ArrayField.choices with lists and tuples.

This commit is contained in:
Hasan Ramezani 2019-10-31 20:33:16 +01:00 committed by Mariusz Felisiak
parent dc60597eb6
commit 47379d027b
4 changed files with 35 additions and 1 deletions

View file

@ -10,7 +10,7 @@ from django.test import override_settings
from django.utils import timezone
from . import PostgreSQLSimpleTestCase, PostgreSQLTestCase
from .models import RangeLookupsModel, RangesModel
from .models import PostgreSQLModel, RangeLookupsModel, RangesModel
try:
from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange
@ -413,6 +413,18 @@ class TestSerialization(PostgreSQLSimpleTestCase):
self.assertEqual(new_instance.ints, NumericRange(10, None))
class TestChecks(PostgreSQLSimpleTestCase):
def test_choices_tuple_list(self):
class Model(PostgreSQLModel):
field = pg_fields.IntegerRangeField(
choices=[
['1-50', [((1, 25), '1-25'), ([26, 50], '26-50')]],
((51, 100), '51-100'),
],
)
self.assertEqual(Model._meta.get_field('field').check(), [])
class TestValidators(PostgreSQLSimpleTestCase):
def test_max(self):