plugin.py 文件源码

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

项目:pytest-cython 作者: lgpage 项目源码 文件源码
def pytest_collect_file(path, parent):
    bin_exts = ['.so']
    cy_exts = ['.pyx', '.py']  # collect .so files if .py file exists
    ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")

    config = parent.config
    if path.ext in bin_exts:
        if config.getoption('--doctest-cython'):
            if ext_suffix is None:
                bin_file = path
                # XXX EXT_SUFFIX is None for pypy (python2.7)
                if '.pypy' in path.basename:
                    basename = path.basename.split('.')[0]
                    bin_file = path.new(purebasename=basename, ext=path.ext)

            else:
                basename = path.basename.replace(ext_suffix, "")
                bin_file = path.new(purebasename=basename, ext=path.ext)

            pyx_file = _find_matching_pyx_file(bin_file, cy_exts)
            # only run test if matching .so and .pyx files exist
            # create addoption for this ??
            if pyx_file is not None:
                return DoctestModule(path, parent)


# XXX patch pyimport to support PEP 3149
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号