#NEWLINE# def test_init_logging( self ) : #NEWLINE# #INDENT# log_dir = os . path . join ( os . path . dirname ( __file__ ) , 'resources' , 'log' ) #NEWLINE# log_file = 'test.log' #NEWLINE# log_path = os . path . join ( log_dir , log_file ) #NEWLINE# with MockTransaction : #NEWLINE# #INDENT# logging . root = mock ( 'root' ) #NEWLINE# expect ( logging ) . disable ( logging . CRITICAL ) . once ( ) #NEWLINE# expect ( logging . root ) . setLevel . never ( ) #NEWLINE# expect ( logging . root ) . addHandler . never ( ) #NEWLINE# assert common . init_logging ( log_dir , log_file , 0 ) #NEWLINE# #UNINDENT# with MockTransaction : #NEWLINE# #INDENT# shutil . rmtree ( log_dir , True ) #NEWLINE# logging . root = mock ( 'root' ) #NEWLINE# expect ( logging ) . disable . never ( ) #NEWLINE# expect ( logging . root ) . setLevel ( logging . WARNING ) . once ( ) #NEWLINE# handler = mock ( 'handler' ) #NEWLINE# expect ( logging ) . FileHandler ( log_path ) . and_return ( handler ) . once ( ) #NEWLINE# expect ( handler ) . setFormatter . and_return ( True ) . once ( ) #NEWLINE# expect ( logging ) . Formatter ( '%(asctime)s %(levelname)-8s %(name)s %(message)s' ) . once ( ) #NEWLINE# expect ( logging . root ) . addHandler . once ( ) #NEWLINE# assert common . init_logging ( self , log_file , 1 ) #NEWLINE# assert os . access ( log_dir , os . W_OK ) #NEWLINE# #UNINDENT# with MockTransaction : #NEWLINE# #INDENT# logging . root = mock ( 'root' ) #NEWLINE# expect ( logging ) . disable . never ( ) #NEWLINE# expect ( logging . root ) . setLevel ( logging . INFO ) . once ( ) #NEWLINE# handler = mock ( 'handler' ) #NEWLINE# expect ( logging ) . FileHandler ( log_path ) . and_return ( handler ) . once ( ) #NEWLINE# expect ( handler ) . setFormatter . and_return ( True ) . once ( ) #NEWLINE# expect ( logging ) . Formatter ( '%(asctime)s %(levelname)-8s %(name)s %(message)s' ) . once ( ) #NEWLINE# expect ( logging . root ) . addHandler . once ( ) #NEWLINE# assert common . init_logging ( log_dir , log_file , 2 ) #NEWLINE# assert os . access ( log_dir , os . W_OK ) #NEWLINE# #UNINDENT# with MockTransaction : #NEWLINE# #INDENT# logging . root = mock ( 'root' ) #NEWLINE# expect ( logging ) . disable . never ( ) #NEWLINE# expect ( logging . root ) . setLevel ( logging . DEBUG ) . once ( ) #NEWLINE# handler = mock ( 'handler' ) #NEWLINE# expect ( logging ) . FileHandler ( log_path ) . and_return ( handler ) . once ( ) #NEWLINE# expect ( handler ) . setFormatter . and_return ( True ) . once ( ) #NEWLINE# expect ( logging ) . Formatter ( '%(asctime)s %(levelname)-8s %(name)s %(message)s' ) . once ( ) #NEWLINE# expect ( logging . root ) . addHandler . once ( ) #NEWLINE# assert common . init_logging ( log_dir , log_file , 3 ) #NEWLINE# assert os . access ( log_dir , os . W_OK ) #NEWLINE# #UNINDENT# shutil . rmtree ( log_dir , True )