test_version.py 文件源码

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

项目:intel-manager-for-lustre 作者: intel-hpdd 项目源码 文件源码
def make_plugin_module(version=None, name="test_plugin_name", extra_body=None):
    """Creates a plugin module with only the version field, optionally

    The module is added to sys.modules, and both the name and module returned.
    """

    #  Create a plugin encoded with a version
    plugin_module = imp.new_module(name)

    if version is not None:
        plugin_module_body = "version = %s" % version
    else:
        plugin_module_body = ""

    if extra_body is not None:
        plugin_module_body = "%s\n\n%s" % (plugin_module_body, extra_body)

    exec plugin_module_body in plugin_module.__dict__

    #  Simulate imported
    sys.modules[name] = plugin_module

    return name, plugin_module
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号