<s> from nose . tools import assert_equals , assert_raises <EOL> from . . log . mixin import LoggerMixin <EOL> class LoggableStub ( object , LoggerMixin ) : <EOL> pass <EOL> def test_logger_mixin ( ) : <EOL> obj = LoggableStub ( ) <EOL> from logging . handlers import MemoryHandler <EOL> import logging <EOL> log = logging . getLogger ( ) <EOL> handler = MemoryHandler ( <NUM_LIT> ) <EOL> log . setLevel ( logging . DEBUG ) <EOL> log . addHandler ( handler ) <EOL> obj . debug ( "<STR_LIT>" ) <EOL> obj . info ( "<STR_LIT>" ) <EOL> obj . warning ( "<STR_LIT>" ) <EOL> obj . error ( "<STR_LIT>" ) <EOL> obj . critical ( "<STR_LIT>" ) <EOL> obj . exception ( "<STR_LIT>" ) <EOL> obj . exception ( ) <EOL> assert_equals ( len ( handler . buffer ) , <NUM_LIT:7> ) <EOL> assert_equals ( handler . buffer [ <NUM_LIT:2> ] . name , "<STR_LIT>" ) <EOL> assert_equals ( handler . buffer [ <NUM_LIT:2> ] . msg , "<STR_LIT>" ) <EOL> log . removeHandler ( handler ) <EOL> def test_logger_raises_on_invalid_name_type ( ) : <EOL> class BrokenLoggableStub ( object , LoggerMixin ) : <EOL> def _logger_name ( self ) : <EOL> return <NUM_LIT> <EOL> broken_logger = BrokenLoggableStub ( ) <EOL> assert_raises ( <EOL> TypeError , <EOL> broken_logger . debug , <EOL> "<STR_LIT>" ) </s>
