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