assertions.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:oa_qian 作者: sunqb 项目源码 文件源码
def expect_deprecated(*messages):
    # todo: should probably be strict about this, too
    filters = [dict(action='ignore',
                    category=sa_exc.SAPendingDeprecationWarning)]
    if not messages:
        filters.append(dict(action='ignore',
                            category=sa_exc.SADeprecationWarning))
    else:
        filters.extend(
            [dict(action='ignore',
                  message=message,
                  category=sa_exc.SADeprecationWarning)
             for message in
             [(m.startswith('//') and
               ('Call to deprecated function ' + m[2:]) or m)
              for m in messages]])

    for f in filters:
        warnings.filterwarnings(**f)
    try:
        yield
    finally:
        resetwarnings()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号