【问题标题】:nosetests running tests for specific class in multi class python file -m doesnt work!!!! arggh在多类 python 文件中为特定类运行测试的nosetests -m 不起作用!!!!啊啊啊
【发布时间】:2014-04-24 04:26:28
【问题描述】:

我已经解决这个问题一天了。 :( 想不通。请帮忙。 我有这个设置:

类父(对象): pass # 常见的东西放在这里

A 类(父母,unittest.TestCase): pass #这里的东西

B 类(父母,unittest.TestCase): 在这里传递#B的东西

我想使用鼻子测试只运行 B 类和父类的测试,因为 B 继承自父类。我以为我会使用 -m 或 --match 来放置类名,但它似乎不起作用。

默认匹配使用 --match is '(?:^|[\b_./-])[Tt]est'

有什么想法吗?

提前致谢!

【问题讨论】:

    标签: nosetests


    【解决方案1】:

    首先,查看Nose's documentation about test selection。这比您尝试做的要容易得多!如果所有测试类AB 都在一个名为mytests.py 的文件中,则此命令将只运行类A 的测试:

    nosetests mytests.py:A
    

    您可以进一步将执行限制为A 类的单个方法:

    nosetests mytests.py:A.testOne
    

    这些可以组合。要运行A 的所有测试方法,并且只运行BtestTwo 方法,试试这个:

    nosetests mytests.py:A mytests.py:B.testTwo
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-12
      相关资源
      最近更新 更多