#NEWLINE# def login( self ) : #NEWLINE# #INDENT# "If not already set, creates self.username and self.password,\n        otherwise uses the existing values.\n        If there's not already a user with that username, creates one.\n        Sets self.user to that user.\n        Logs the user in.\n        " #NEWLINE# if ( not hasattr ( self , 'username' ) ) : #NEWLINE# #INDENT# self . username = 'fred' #NEWLINE# #UNINDENT# if ( not hasattr ( self , 'password' ) ) : #NEWLINE# #INDENT# self . password = 'bob' #NEWLINE# #UNINDENT# if ( not User . objects . filter ( username = self . username ) . exists ( ) ) : #NEWLINE# #INDENT# User . objects . create_user ( self . username , password = self . password ) #NEWLINE# #UNINDENT# self . user = User . objects . get ( username = self . username ) #NEWLINE# logged_in = self . client . login ( username = self . username , password = self . password ) #NEWLINE# if ( not logged_in ) : #NEWLINE# #INDENT# self . fail ( 'LOGIN failed' )