Ticket #25299: 25299-test.diff

File 25299-test.diff, 1.4 KB (added by Tim Graham, 5 years ago)
  • tests/admin_views/admin.py

    diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
    index 367ac3d..b13bd32 100644
    a b class ThingAdmin(admin.ModelAdmin): 
    169169
    170170
    171171class InquisitionAdmin(admin.ModelAdmin):
    172     list_display = ('leader', 'country', 'expected')
     172    list_display = ('leader', 'country', 'expected', 'sketch')
     173
     174    def sketch(self, obj):
     175        # A method with the same name as a reverse accessor.
     176        return 'list-display-sketch'
    173177
    174178
    175179class SketchAdmin(admin.ModelAdmin):
  • tests/admin_views/tests.py

    diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
    index 9e6c349..ef16eb7 100644
    a b class RawIdFieldsTest(TestCase): 
    48824882        self.assertNotContains(response2, "Kilbraken")
    48834883        self.assertContains(response2, "Palin")
    48844884
     4885    def test_list_display_method_same_name_as_reverse_accessor(self):
     4886        actor = Actor.objects.create(name="Palin", age=27)
     4887        Inquisition.objects.create(expected=True, leader=actor, country="England")
     4888        response = self.client.get(reverse('admin:admin_views_inquisition_changelist'))
     4889        self.assertContains(response, 'list-display-sketch')
     4890
    48854891
    48864892@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
    48874893    ROOT_URLCONF="admin_views.urls")
Back to Top