<s> __author__ = '<STR_LIT>' <EOL> from nose . plugins import Plugin <EOL> import nose <EOL> import warnings <EOL> class WarnAsError ( Plugin ) : <EOL> enabled = False <EOL> def options ( self , parser , env ) : <EOL> """<STR_LIT>""" <EOL> super ( ) . options ( parser , env ) <EOL> parser . add_option ( "<STR_LIT>" , action = "<STR_LIT:store_true>" , <EOL> default = False , <EOL> dest = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> def configure ( self , options , conf ) : <EOL> """<STR_LIT>""" <EOL> super ( ) . configure ( options , conf ) <EOL> if options . warnaserror : <EOL> self . enabled = True <EOL> def prepareTestRunner ( self , runner ) : <EOL> """<STR_LIT>""" <EOL> if self . enabled : <EOL> return WarnAsErrorTestRunner ( runner ) <EOL> else : <EOL> return runner <EOL> class WarnAsErrorTestRunner ( object ) : <EOL> def __init__ ( self , runner ) : <EOL> self . runner = runner <EOL> def run ( self , test ) : <EOL> with warnings . catch_warnings ( ) : <EOL> warnings . simplefilter ( "<STR_LIT:error>" ) <EOL> warnings . filterwarnings ( <EOL> "<STR_LIT:ignore>" , <EOL> message = "<STR_LIT>" , <EOL> category = DeprecationWarning , <EOL> module = "<STR_LIT>" <EOL> ) <EOL> warnings . filterwarnings ( <EOL> "<STR_LIT:ignore>" , <EOL> message = "<STR_LIT>" , <EOL> category = DeprecationWarning , <EOL> module = "<STR_LIT>" <EOL> ) <EOL> return self . runner . run ( test ) </s>
