#NEWLINE# def test_books_queryset_get( self ) : #NEWLINE# #INDENT# author = Author . objects . create ( name = 'John Doe' ) #NEWLINE# for i in range ( 3 ) : #NEWLINE# #INDENT# Book . objects . create ( name = ( 'Book %s' % i ) , author = author ) #NEWLINE# #UNINDENT# i = Author . objects . prefetch ( 'books' ) . get ( pk = author . pk ) #NEWLINE# self . assertTrue ( hasattr ( self , 'prefetched_books' ) ) #NEWLINE# self . assertEqual ( len ( i . books ) , 3 , i . books ) #NEWLINE# i = Author . objects . get ( name = 'John Doe' ) #NEWLINE# self . assertFalse ( hasattr ( i , 'prefetched_books' ) ) #NEWLINE# self . assertEqual ( len ( i . books ) , 3 , i . books )