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
评论列表
文章目录