我已经成功地使用了nose.run(argv=['--with-doctest'], addplugins=[...]),但是现在我需要创建nose.plugins.doctests.Doctest的子类,这样我就可以修改它的loadTestsFromModule方法。我有其他插件(通过nose.plugins.Plugin的子类化)正在工作,但我还没有成功地运行文档测试。
from nose.plugins.doctests import Doctest
class TestDocs(Doctest):
def loadTestsFromModule(self, module):
# add something here
super(testDocs, self).__init__(module)我尝试过以下几种方法:
nose.run(addplugins=[TestDocs()])
nose.run(plugins=[TestDocs()])
nose.run(argv=['--with-testdocs'])
nose.run(argv=['--with-testdocs'], addplugins=[TestDocs()])我还尝试了另一个名称,以防它包含'test‘是一个问题。我尝试过直接使用DocTest,但是不使用--with-doctest就无法激活doctests。
nose.run(addplugins=[Doctest()])
nose.run(plugins=[Doctest()])如何使用插件激活doctest?
发布于 2019-10-29 04:49:28
这种组合允许使用nose.run的Doctest的自定义子类。
nose.run(argv=['--with-testdocs'], plugins=[TestDocs()])使用argv=['--plugins']很有帮助,因为它突出了plugins=和addplugins=之间的区别,因为我已经在使用其他插件的插件了:
>>> nose.run(argv=['--plugins'], plugins=[TestDocs()],
addplugins=[OtherPlugin(), AnotherPlugin()])
Plugin OtherPlugin
Plugin testdocs
Plugin AnotherPluginhttps://stackoverflow.com/questions/58585082
复制相似问题