【问题标题】:Nose collect tests in a directory鼻子在目录中收集测试
【发布时间】:2013-02-18 20:34:41
【问题描述】:

我正在尝试从 python 脚本中使用鼻子收集特定目录中的所有测试。

我的目录结构是这样的

script.py
test_dir/
  testsetA/testA1.py
           testA2.py
           __init__.py
  testsetB/testB1.py
           testB2.py
           __init__.py
  testsetC/...

从 script.py,我喜欢流鼻涕

args = ['-w test_dir/testsetA/', '--collect-only']   
nose.run(argv=args)

问题是,它似乎收集了 testsetA、B、C 等中的所有测试,而不是像我期望的那样只收集 testsetA 中的两个。我可能可以使用 --with-id 选项并找出哪些测试在 testsetA 中,但我宁愿只从我指定的目录中收集测试。有没有办法做到这一点?

【问题讨论】:

    标签: python nose


    【解决方案1】:

    如果你使用的是 Python 3.X,你应该这样写:

    args = ['--py3where', 'test_dir/testsetA/', '--collect-only'] 
    

    【讨论】:

      【解决方案2】:

      您应该从目录中拆分-w

      args = ['-w', 'test_dir/testsetA/', '--collect-only'] 
      

      否则nose 会认为'-w test_dir/testsetA/ 是单个参数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多