def assert_warnings(fn, warnings, regex=False):

    from .assertions import eq_, emits_warning

    canary = []
    orig_warn = util.warn

    def capture_warnings(*args, **kw):
        orig_warn(*args, **kw)
        popwarn = warnings.pop(0)
        canary.append(popwarn)
        if regex:
            assert re.match(popwarn, args[0])
        else:
            eq_(args[0], popwarn)
    util.warn = util.langhelpers.warn = capture_warnings

    result = emits_warning()(fn)()
    assert canary, "No warning was emitted"
    return result
Return symbolic gradients for one or more variables with respect to some
dataset/ETHPy150Open RoseOu/flasky/venv/lib/python2.7/site-packages/sqlalchemy/testing/warnings.py/assert_warnings--crossover with--dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/gradient.py/grad