diff options
Diffstat (limited to 'tests/contenttypes_tests')
| -rw-r--r-- | tests/contenttypes_tests/test_checks.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/contenttypes_tests/test_checks.py b/tests/contenttypes_tests/test_checks.py index 6b33107de2..44cd3c2758 100644 --- a/tests/contenttypes_tests/test_checks.py +++ b/tests/contenttypes_tests/test_checks.py @@ -1,5 +1,6 @@ from unittest import mock +from django.contrib.contenttypes.checks import check_model_name_lengths from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) @@ -216,3 +217,20 @@ class GenericRelationTests(SimpleTestCase): id='fields.E001', ) ]) + + +@isolate_apps('contenttypes_tests', attr_name='apps') +class ModelCheckTests(SimpleTestCase): + def test_model_name_too_long(self): + model = type('A' * 101, (models.Model,), {'__module__': self.__module__}) + self.assertEqual(check_model_name_lengths(self.apps.get_app_configs()), [ + checks.Error( + 'Model names must be at most 100 characters (got 101).', + obj=model, + id='contenttypes.E005', + ) + ]) + + def test_model_name_max_length(self): + type('A' * 100, (models.Model,), {'__module__': self.__module__}) + self.assertEqual(check_model_name_lengths(self.apps.get_app_configs()), []) |
