2

我遇到了这个 py.test 问题报告中描述的问题: https ://bitbucket.org/hpk42/pytest/issue/27/collectonly-doesnt-respect-k

这些是来自 Jenkins 控制台的结果:~~~~~~~~~~~~~~~~~~ + py.test -v -k test_example --junitxml=functionaltests/reports/res.xml === ========================== 测试开始 ===================== ========= 平台 linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /var/lib/jenkins/shiningpanda/jobs/9df20569/virtualenvs/701cc1aa/bin/python2.7 插件: xdist 收集...收集了 3 个项目 / 1 个错误

functionaltests/test_example.py:40: test_data[apple] PASSED
functionaltests/test_example.py:40: test_data[pear] PASSED
functionaltests/test_example.py:40: test_data[berry] PASSED

==================================== ERRORS ====================================
___________ ERROR collecting functionaltests/test_smm_healthcheck.py ___________
functionaltests/test_smm_healthcheck.py:2: in <module>
>   import models.SMMMicrosites as site_data
E   ImportError: No module named models.SMMMicrosites
 generated xml file: /var/lib/jenkins/workspace/WT/functionaltests/reports/res.xml 
====================== 3 passed, 1 error in 0.05 seconds =======================
Build step 'Virtualenv Builder' marked build as failure
Recording test results
Finished: FAILURE

~~~~~~~~~~~~~~~~~~

不应收集或执行测试模块“test_smm_healthcheck.py”。修复 - 已解决 - 尚未发布?我正在运行 py.test 2.3.4 版。

4

1 回答 1

1

“-k”标志不影响收集的内容 - 仅影响使用 --collectonly 报告的内容。所以你不能用它来阻止收集。您可以使用 --ignore=path (一次或多次)来防止收集。

于 2013-01-28T09:28:20.457 回答