【问题标题】:python nose plugins hook methods not workpython鼻子插件钩子方法不起作用
【发布时间】:2014-01-14 21:01:09
【问题描述】:

我想使用nose 运行我的测试套件,该套件由unnittest.TestCase 的extends 编写。 我有一个覆盖钩子方法的插件: startTest() stopTest() beforeTest()..

下面是我的代码:

names = ['module.testclass.testMethod1','module.testclass.testMethod2']
tests = []
for i in names:
    tests.append(unittest.TestLoader().loadTestsFromName(i))

suites = unittest.suite.TestSuite(tests)

inputs = ['','--verbosity=2', '--with-my-plugin']

nose.run(argv=inputs, suite=suites)

但我发现 my-plugin 中的所有钩子方法,例如:startTest() stopTest() beforeTest() afterTest() 都不会被调用。有人能告诉我为什么吗?谢谢

【问题讨论】:

    标签: python nose


    【解决方案1】:

    我应该使用nose提供的标准格式来搜索测试方法:

    names = ['module:testclass.testMethod1','module:testclass.testMethod2']

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-22
      • 2013-05-27
      • 2021-10-15
      • 1970-01-01
      • 1970-01-01
      • 2013-06-09
      • 1970-01-01
      • 2023-03-18
      相关资源
      最近更新 更多