Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入后停止doctest_Python_Import_Doctest - Fatal编程技术网

Python 导入后停止doctest

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(

我试图在我的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("hello")
Expecting:

    hello
ok
Trying:

    from filetotest import *

Expecting nothing
因此,在我尝试从
filetotest
doctest导入函数后,不要尝试文件中的其余部分,我要做的是测试
filetotest
中的函数


有什么问题,为什么会停止?

使用“.txt”作为文件扩展名可能会破坏Python的导入系统。用“.py”代替。你好!谢谢你的回答!我认为这不是问题所在,因为我可以毫无问题地导入包含代码类的文件