doctesting.py 文件源码

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

项目:respeaker_virtualenv 作者: respeaker 项目源码 文件源码
def get_doctests(text_file_dir):
    """
    Return a list of TestSuite instances for all doctests in the project.

    Arguments:

      text_file_dir: the directory in which to search for all text files
        (i.e. non-module files) containing doctests.

    """
    # Since module_relative is False in our calls to DocFileSuite below,
    # paths should be OS-specific.  See the following for more info--
    #
    #   http://docs.python.org/library/doctest.html#doctest.DocFileSuite
    #
    paths = [os.path.normpath(os.path.join(text_file_dir, path)) for path in TEXT_DOCTEST_PATHS]

    if sys.version_info >= (3,):
        # Skip the README doctests in Python 3 for now because examples
        # rendering to unicode do not give consistent results
        # (e.g. 'foo' vs u'foo').
        # paths = _convert_paths(paths)
        paths = []

    suites = []

    for path in paths:
        suite = doctest.DocFileSuite(path, module_relative=False)
        suites.append(suite)

    modules = get_module_names()
    for module in modules:
        suite = doctest.DocTestSuite(module)
        suites.append(suite)

    return suites
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号