diff options
Diffstat (limited to 'tests/admin_checks/tests.py')
| -rw-r--r-- | tests/admin_checks/tests.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py index fa1bcc1518..d243a56640 100644 --- a/tests/admin_checks/tests.py +++ b/tests/admin_checks/tests.py @@ -7,7 +7,9 @@ from django.contrib.contenttypes.admin import GenericStackedInline from django.core import checks from django.test import SimpleTestCase, override_settings -from .models import Album, Book, City, Influence, Song, State, TwoAlbumFKAndAnE +from .models import ( + Album, Author, Book, City, Influence, Song, State, TwoAlbumFKAndAnE, +) class SongForm(forms.ModelForm): @@ -52,7 +54,6 @@ class SystemChecksTestCase(SimpleTestCase): self.assertEqual(errors, expected) finally: admin.site.unregister(Song) - admin.sites.system_check_errors = [] @override_settings(INSTALLED_APPS=['django.contrib.admin']) def test_contenttypes_dependency(self): @@ -105,7 +106,27 @@ class SystemChecksTestCase(SimpleTestCase): self.assertEqual(errors, expected) finally: custom_site.unregister(Song) - admin.sites.system_check_errors = [] + + @override_settings(DEBUG=True) + def test_allows_checks_relying_on_other_modeladmins(self): + class MyBookAdmin(admin.ModelAdmin): + def check(self, **kwargs): + errors = super(MyBookAdmin, self).check(**kwargs) + author_admin = self.admin_site._registry.get(Author) + if author_admin is None: + errors.append('AuthorAdmin missing!') + return errors + + class MyAuthorAdmin(admin.ModelAdmin): + pass + + admin.site.register(Book, MyBookAdmin) + admin.site.register(Author, MyAuthorAdmin) + try: + self.assertEqual(admin.site.check(None), []) + finally: + admin.site.unregister(Book) + admin.site.unregister(Author) def test_field_name_not_in_list_display(self): class SongAdmin(admin.ModelAdmin): |
