#NEWLINE# @ override_settings ( ADMINS = ( ( 'whatever admin' , 'admin@example.com' ) , ) , EMAIL_SUBJECT_PREFIX = '-SuperAwesomeSubject-' , INTERNAL_IPS = ( '127.0.0.1' , ) ) #NEWLINE# def test_accepts_args_and_request( self ) : #NEWLINE# #INDENT# '\n        Ensure that the subject is also handled if being\n        passed a request object.\n        ' #NEWLINE# message = "Custom message that says '%s' and '%s'" #NEWLINE# token1 = 'ping' #NEWLINE# token2 = 'pong' #NEWLINE# admin_email_handler = self . get_admin_email_handler ( self . logger ) #NEWLINE# orig_filters = admin_email_handler . filters #NEWLINE# try : #NEWLINE# #INDENT# admin_email_handler . filters = [ ] #NEWLINE# rf = RequestFactory ( ) #NEWLINE# request = rf . get ( '/' ) #NEWLINE# self . logger . error ( message , token1 , token2 , extra = { #NEWLINE# #INDENT# 'status_code' : 403 , #NEWLINE# 'request' : request , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( len ( mail . outbox ) , 1 ) #NEWLINE# self . assertEqual ( mail . outbox [ 0 ] . to , [ 'admin@example.com' ] ) #NEWLINE# self . assertEqual ( mail . outbox [ 0 ] . subject , "-SuperAwesomeSubject-ERROR (internal IP): Custom message that says 'ping' and 'pong'" ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# admin_email_handler . filters = orig_filters