Ticket #24316: 24316_test_case_1.diff
File 24316_test_case_1.diff, 2.2 KB (added by , 9 years ago) |
---|
-
tests/admin_changelist/admin.py
diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py index 99deafc..ddc0316 100644
a b class CustomPaginator(Paginator): 17 17 18 18 19 19 class EventAdmin(admin.ModelAdmin): 20 list_display = ['event_date_func'] 20 event_year_lambda = lambda event: event.date.year 21 event_year_lambda.short_description = 'Year' 22 23 list_display = ['event_date_func', event_year_lambda] 21 24 22 25 def event_date_func(self, event): 23 26 return event.date 27 event_date_func.short_description = "Event date" 24 28 25 29 site.register(Event, EventAdmin) 26 30 -
tests/admin_changelist/tests.py
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index ded3bfc..251c38d 100644
a b class ChangeListTests(TestCase): 441 441 self.assertContains(response, formats.localize(event.date)) 442 442 self.assertNotContains(response, six.text_type(event.date)) 443 443 444 def test_list_display_css_class_of_function_uses_short_description_in_th(self): 445 User.objects.create_superuser( 446 username='super', email='super@localhost', password='secret') 447 self.client.login(username='super', password='secret') 448 event = Event.objects.create(date=datetime.date.today()) 449 response = self.client.get('/admin/admin_changelist/event/') 450 self.assertNotContains(response, 'class="column-<function EventAdmin.<lambda>') 451 self.assertContains(response, 'class="column-year"') 452 453 def test_list_display_css_class_of_function_uses_short_description_in_td(self): 454 User.objects.create_superuser( 455 username='super', email='super@localhost', password='secret') 456 self.client.login(username='super', password='secret') 457 event = Event.objects.create(date=datetime.date.today()) 458 response = self.client.get('/admin/admin_changelist/event/') 459 self.assertNotContains(response, 'class="field-<function EventAdmin.<lambda>') 460 self.assertContains(response, 'class="field-year"') 461 444 462 def test_dynamic_list_display(self): 445 463 """ 446 464 Regression tests for #14206: dynamic list_display support.