imp后停止测试

2024-09-30 01:23:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在我的Python代码上运行doctest。你知道吗

我用这个来运行doctest

import doctest
doctest.testfile("test.txt", verbose=True)

test.txt文件如下所示:

print("hello")

hello
from filetotest import *

print("hello")

hello

我的问题是,在第3行from filetotest import *之后,doctest停止运行doctest

Trying:

    print("hello")
Expecting:

    hello
ok
Trying:

    from filetotest import *

Expecting nothing

因此,在我尝试从filetotest导入函数后,doctest不要尝试文件中的其余函数,我要做的是测试filetotest中的函数。你知道吗

怎么了,为什么停了?你知道吗


Tags: 文件函数代码fromtestimporttxthello

热门问题