plugin.py 文件源码

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

项目:pytest-cython 作者: lgpage 项目源码 文件源码
def _patch_pyimport(fspath, **kwargs):
    ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
    # XXX EXT_SUFFIX is None for pypy (python2.7)
    if ext_suffix is None and '.pypy' not in fspath.basename:
        return fspath.pyimport(**kwargs)

    else:
        # XXX EXT_SUFFIX is None for pypy (python2.7)
        if '.pypy' in fspath.basename:
            ext_suffix = fspath.ext
            basename = fspath.basename.split('.')[0]
            fspath = fspath.new(purebasename=basename, ext=fspath.ext)

        pkgroot = fspath.dirpath()
        fspath._ensuresyspath(True, pkgroot)
        names = fspath.relto(pkgroot).split(fspath.sep)
        modname = ".".join(names).replace(ext_suffix, "")
        __import__(modname)
        return sys.modules[modname]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号