Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.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 3.x 修改并运行nose-Doctest插件_Python 3.x_Nose - Fatal编程技术网

Python 3.x 修改并运行nose-Doctest插件

Python 3.x 修改并运行nose-Doctest插件,python-3.x,nose,Python 3.x,Nose,我已经成功地使用了nose.run(argv=['--with doctest'],addplugins=[…]),但现在我需要对nose.plugins.doctests.doctest进行子类化,以便修改它的loadTestsFromModule方法。我还有其他插件(通过子类化nose.plugins.Plugin)正在工作,但我没有成功运行doctests 从nose.plugins.doctests导入Doctest 类TestDocs(Doctest): def loadTestsFr

我已经成功地使用了
nose.run(argv=['--with doctest'],addplugins=[…])
,但现在我需要对
nose.plugins.doctests.doctest
进行子类化,以便修改它的
loadTestsFromModule
方法。我还有其他插件(通过子类化
nose.plugins.Plugin
)正在工作,但我没有成功运行doctests

从nose.plugins.doctests导入Doctest
类TestDocs(Doctest):
def loadTestsFromModule(自身,模块):
#在这里添加一些内容
super(testDocs,self)。\uuuu init\uuuu(模块)
我尝试了以下方法:

nose.run(addplugins=[TestDocs()])
run(插件=[TestDocs()])
run(argv=['--with testdocs'])
run(argv=['--with testdocs'],addplugins=[testdocs()])
我还尝试了另一个名字,以防它包括“测试”是一个问题。我试着直接使用
DocTest
,但是没有使用
——使用DocTest
,就无法激活DocTest

nose.run(addplugins=[Doctest()])
nose.run(plugins=[Doctest()])

如何使用插件激活Doctest?

此组合允许使用
nose.run
自定义子类
Doctest

nose.run(argv=['--with-testdocs'], plugins=[TestDocs()])
使用
argv=['--plugins']
很有帮助,因为它突出了
plugins=
addplugins=
之间的区别,因为我已经在为其他插件使用addplugins了

>>> nose.run(argv=['--plugins'], plugins=[TestDocs()], 
             addplugins=[OtherPlugin(), AnotherPlugin()])
Plugin OtherPlugin
Plugin testdocs
Plugin AnotherPlugin