db.py 文件源码

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

项目:panko 作者: openstack 项目源码 文件源码
def run_with(*drivers):
    """Used to mark tests that are only applicable for certain db driver.

    Skips test if driver is not available.
    """
    def decorator(test):
        if isinstance(test, type) and issubclass(test, TestBase):
            # Decorate all test methods
            for attr in dir(test):
                value = getattr(test, attr)
                if callable(value) and attr.startswith('test_'):
                    if six.PY3:
                        value._run_with = drivers
                    else:
                        value.__func__._run_with = drivers
        else:
            test._run_with = drivers
        return test
    return decorator
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号