diff options
| author | Eric Blum <eric@enertiv.com> | 2025-05-01 16:31:06 -0400 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-05-08 11:38:13 +0100 |
| commit | 384cdf0f7a2c8d1793b120d82a1584776c064f44 (patch) | |
| tree | 17234cad549df8802cd487f3c4f161ed2c236984 /tests | |
| parent | 358fd21c47cdf7bda520ce73c5cfd82bba57827b (diff) | |
Fixed #36363 -- Added field names to admin duplicated fields error hint.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_checks/tests.py | 28 | ||||
| -rw-r--r-- | tests/modeladmin/test_checks.py | 3 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py index 6ca5d6d925..fc87260c9c 100644 --- a/tests/admin_checks/tests.py +++ b/tests/admin_checks/tests.py @@ -479,6 +479,7 @@ class SystemChecksTestCase(SimpleTestCase): expected = [ checks.Error( "The value of 'exclude' contains duplicate field(s).", + hint="Remove duplicates of 'name'.", obj=ExcludedFields2, id="admin.E015", ) @@ -970,6 +971,7 @@ class SystemChecksTestCase(SimpleTestCase): expected = [ checks.Error( "The value of 'fields' contains duplicate field(s).", + hint="Remove duplicates of 'state'.", obj=MyModelAdmin, id="admin.E006", ) @@ -986,12 +988,38 @@ class SystemChecksTestCase(SimpleTestCase): expected = [ checks.Error( "There are duplicate field(s) in 'fieldsets[0][1]'.", + hint="Remove duplicates of 'title', 'album'.", obj=MyModelAdmin, id="admin.E012", ) ] self.assertEqual(errors, expected) + def test_check_multiple_duplicates_across_fieldsets(self): + class MyModelAdmin(admin.ModelAdmin): + fieldsets = [ + ("Header 1", {"fields": ["title", "album"]}), + ("Header 2", {"fields": ["album", "name"]}), + ("Header 3", {"fields": ["name", "other", "title"]}), + ] + + errors = MyModelAdmin(Song, AdminSite()).check() + expected = [ + checks.Error( + "There are duplicate field(s) in 'fieldsets[1][1]'.", + hint="Remove duplicates of 'album'.", + obj=MyModelAdmin, + id="admin.E012", + ), + checks.Error( + "There are duplicate field(s) in 'fieldsets[2][1]'.", + hint="Remove duplicates of 'title', 'name'.", + obj=MyModelAdmin, + id="admin.E012", + ), + ] + self.assertEqual(errors, expected) + def test_list_filter_works_on_through_field_even_when_apps_not_ready(self): """ Ensure list_filter can access reverse fields even when the app registry diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py index 94a80ca006..0592be7b4f 100644 --- a/tests/modeladmin/test_checks.py +++ b/tests/modeladmin/test_checks.py @@ -222,6 +222,7 @@ class FieldsetsCheckTests(CheckTestCase): ValidationTestModel, "There are duplicate field(s) in 'fieldsets[0][1]'.", "admin.E012", + "Remove duplicates of 'name'.", ) def test_duplicate_fields_in_fieldsets(self): @@ -236,6 +237,7 @@ class FieldsetsCheckTests(CheckTestCase): ValidationTestModel, "There are duplicate field(s) in 'fieldsets[1][1]'.", "admin.E012", + "Remove duplicates of 'name'.", ) def test_fieldsets_with_custom_form_validation(self): @@ -255,6 +257,7 @@ class FieldsCheckTests(CheckTestCase): ValidationTestModel, "The value of 'fields' contains duplicate field(s).", "admin.E006", + "Remove duplicates of 'name'.", ) def test_inline(self): |
