#NEWLINE# def test_m2m_then_m2m( self ) : #NEWLINE# #INDENT# with self . assertNumQueries ( 3 ) : #NEWLINE# #INDENT# qs = Department . objects . prefetch_related ( 'teachers' ) #NEWLINE# depts = '' . join ( [ ( '%s department: %s\n' % ( dept . name , ', ' . join ( ( six . text_type ( t ) for t in dept . teachers . all ( ) ) ) ) ) for dept in qs ] ) #NEWLINE# self . assertEqual ( depts , 'English department: Mr Cleese (BA, BSci, MA, PhD), Mr Idle (BA)\nPhysics department: Mr Cleese (BA, BSci, MA, PhD), Mr Chapman (BSci)\n' )