def assert_raises(c, exc):
    """Test whether callable c raises an exception of type exc."""
    try:
        c()
    except exc:
        return True
    else:
        raise AssertionError("%r failed to raise exception %r" % (c, exc))