def setup_warning_catcher():
 caught_warnings = []
 original_showwarning = warnings.showwarning
 def custom_showwarning(*args, **kwargs):
  caught_warnings.append(args[0])
 warnings.showwarning = custom_showwarning
 def restore_showwarning():
  warnings.showwarning = original_showwarning
 return (caught_warnings, restore_showwarning)

def setup_warning_catcher ( ) : caught_warnings = [ ] original_showwarning = warnings . showwarning def custom_showwarning ( * args , ** kwargs ) : caught_warnings . append ( args [ 0 ] ) warnings . showwarning = custom_showwarning def restore_showwarning ( ) : warnings . showwarning = original_showwarning return ( caught_warnings , restore_showwarning )
wrap warnings .