summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2019-10-31 20:33:16 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-11-05 11:48:44 +0100
commit47379d027ba2786403969367ec9c721936a823f8 (patch)
treec2aec2c7500c8910e2eec386697a31b65f2daeff /tests/postgres_tests/test_array.py
parentdc60597eb643814e54fbb0f7dadfe68c634e52fa (diff)
downloaddjango-47379d027ba2786403969367ec9c721936a823f8.tar.gz
Fixed #30095 -- Fixed system check for RangeField/ArrayField.choices with lists and tuples.
Diffstat (limited to 'tests/postgres_tests/test_array.py')
-rw-r--r--tests/postgres_tests/test_array.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 379a1e9bba..7b7793f6c1 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -592,6 +592,20 @@ class TestChecks(PostgreSQLSimpleTestCase):
self.assertEqual(errors[0].id, 'postgres.E001')
self.assertIn('max_length', errors[0].msg)
+ def test_choices_tuple_list(self):
+ class MyModel(PostgreSQLModel):
+ field = ArrayField(
+ models.CharField(max_length=16),
+ choices=[
+ [
+ 'Media',
+ [(['vinyl', 'cd'], 'Audio'), (('vhs', 'dvd'), 'Video')],
+ ],
+ (['mp3', 'mp4'], 'Digital'),
+ ],
+ )
+ self.assertEqual(MyModel._meta.get_field('field').check(), [])
+
@unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific tests")
class TestMigrations(TransactionTestCase):