doctest调用函数的顺序?

问题描述 投票:2回答:2

我很困惑,为什么doctest.testmod()会以奇怪的顺序调用测试函数

from doctest import testmod

def test_forwrite():
    '''
    >>> test_forwrite()
    OP: Done
    '''
    write()

def test_forread():
    '''
    >>> test_forread()
    OP: Done
    '''
    read()

if __name__ == "__main__":
    testmod(verbose = True)

为什么总是先定义其定义的test_forread()的顺序不受检查。

python doctest
2个回答
2
投票
测试按名称排序。从doctest source code

doctest


0
投票
这是因为testmod函数通过按

alphabetical

© www.soinside.com 2019 - 2024. All rights reserved.