Python 导入后停止doctest
我试图在我的Python代码上运行Python 导入后停止doctest,python,import,doctest,Python,Import,Doctest,我试图在我的Python代码上运行doctest 我用它来运行doctest import doctest doctest.testfile("test.txt", verbose=True) 而test.txt文件如下所示: print("hello") hello from filetotest import * print("hello") hello 我的问题是,在filetotest导入的第三行之后,doctest停止运行doctest Trying: print(
doctest
我用它来运行doctest
import doctest
doctest.testfile("test.txt", verbose=True)
而test.txt
文件如下所示:
print("hello")
hello
from filetotest import *
print("hello")
hello
我的问题是,在filetotest导入的第三行之后,
doctest停止运行doctest
Trying:
print("hello")
Expecting:
hello
ok
Trying:
from filetotest import *
Expecting nothing
因此,在我尝试从filetotest
doctest导入函数后,不要尝试文件中的其余部分,我要做的是测试filetotest
中的函数
有什么问题,为什么会停止?使用“.txt”作为文件扩展名可能会破坏Python的导入系统。用“.py”代替。你好!谢谢你的回答!我认为这不是问题所在,因为我可以毫无问题地导入包含代码类的文件