'Reset the warnings registry of a module.  This can be necessary
as the warnings module is buggy in that regard.
See http://bugs.python.org/issue4180'

def reset_module_warnings(self, module):

    if isinstance(module, str):
        module = sys.modules[module]
    try:
        del module.__warningregistry__
    except AttributeError:
        pass
