'Ensure save_warnings_state/restore_warnings_state work correctly.'

def test_save_restore_warnings_state(self):

    with warnings.catch_warnings():
        warnings.simplefilter(u'ignore', DeprecationWarning)
        self.save_warnings_state()
        class MyWarning(Warning, ):
            pass
        warnings.simplefilter(u'error', MyWarning)
        self.assertRaises(Warning, (lambda : warnings.warn(u'warn', MyWarning)))
        self.restore_warnings_state()
        warnings.simplefilter(u'ignore', MyWarning)
        warnings.warn(u'warn', MyWarning)
        self.restore_warnings_state()
