Ticket #24316: 24316_test_case.diff
File 24316_test_case.diff, 2.1 KB (added by , 10 years ago) |
---|
-
tests/admin_changelist/admin.py
diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py index b2bd578..8dbd810 100644
a b class CustomPaginator(Paginator): 18 18 19 19 20 20 class EventAdmin(admin.ModelAdmin): 21 list_display = ['event_date_func'] 21 event_year_lambda = lambda event: event.date.year 22 event_year_lambda.short_description = 'Year' 23 24 list_display = ['event_date_func', event_year_lambda] 22 25 23 26 def event_date_func(self, event): 24 27 return event.date -
tests/admin_changelist/tests.py
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 431999d..38efc22 100644
a b class ChangeListTests(TestCase): 369 369 self.assertContains(response, formats.localize(event.date)) 370 370 self.assertNotContains(response, six.text_type(event.date)) 371 371 372 def test_list_display_css_class_of_function_uses_short_description_in_th(self): 373 User.objects.create_superuser( 374 username='super', email='super@localhost', password='secret') 375 self.client.login(username='super', password='secret') 376 event = Event.objects.create(date=datetime.date.today()) 377 response = self.client.get('/admin/admin_changelist/event/') 378 self.assertNotContains(response, 'class="column-<function <lambda>') 379 self.assertContains(response, 'class="column-year"') 380 381 def test_list_display_css_class_of_function_uses_short_description_in_td(self): 382 User.objects.create_superuser( 383 username='super', email='super@localhost', password='secret') 384 self.client.login(username='super', password='secret') 385 event = Event.objects.create(date=datetime.date.today()) 386 response = self.client.get('/admin/admin_changelist/event/') 387 self.assertNotContains(response, 'class="field-<function <lambda>') 388 self.assertContains(response, 'class="field-year"') 389 372 390 def test_dynamic_list_display(self): 373 391 """ 374 392 Regression tests for #14206: dynamic list_display support.