#NEWLINE# def test_dynamic_list_display( self ) : #NEWLINE# #INDENT# '\n        Regression tests for #14206: dynamic list_display support.\n        ' #NEWLINE# parent = Parent . objects . create ( name = 'parent' ) #NEWLINE# for i in range ( 10 ) : #NEWLINE# #INDENT# Child . objects . create ( name = ( 'child %s' % i ) , parent = parent ) #NEWLINE# #UNINDENT# user_noparents = self . _create_superuser ( 'noparents' ) #NEWLINE# user_parents = self . _create_superuser ( 'parents' ) #NEWLINE# m = custom_site . _registry [ Child ] #NEWLINE# request = self . _mocked_authenticated_request ( '/child/' , user_noparents ) #NEWLINE# response = m . changelist_view ( request ) #NEWLINE# self . assertNotContains ( response , 'Parent object' ) #NEWLINE# list_display = m . get_list_display ( request ) #NEWLINE# list_display_links = m . get_list_display_links ( request , list_display ) #NEWLINE# self . assertEqual ( list_display , [ 'name' , 'age' ] ) #NEWLINE# self . assertEqual ( list_display_links , [ 'name' ] ) #NEWLINE# m = DynamicListDisplayChildAdmin ( Child , admin . site ) #NEWLINE# request = self . _mocked_authenticated_request ( '/child/' , user_parents ) #NEWLINE# response = m . changelist_view ( request ) #NEWLINE# self . assertContains ( response , 'Parent object' ) #NEWLINE# custom_site . unregister ( Child ) #NEWLINE# list_display = m . get_list_display ( request ) #NEWLINE# list_display_links = m . get_list_display_links ( request , list_display_links ) #NEWLINE# self . assertEqual ( list_display , ( 'parent' , 'name' , 'age' ) ) #NEWLINE# self . assertEqual ( list_display_links , [ 'parent' ] ) #NEWLINE# custom_site . register ( Child , ChildAdmin ) #NEWLINE# m = custom_site . _registry [ Child ] #NEWLINE# request = self . _mocked_authenticated_request ( '/child/' , user_noparents ) #NEWLINE# response = m . changelist_view ( request ) #NEWLINE# self . assertContains ( response , 'Parent object' )