pytest正在运行测试用例,即使我指定只使用--collect-only来收集测试用例

时间:2016-07-20 10:35:11

标签: python django unit-testing pytest python-unittest

我有一个环境需要使用pexpect测试命令行脚本。我编写了测试用例,我使用pytest来自动执行测试用例。我的pytest.ini文件看起来像这样

[pytest]
python_files=check_*.py
python_functions=test

check_host.py的内容是

import pytest,pretest
def pre_test():
    assert(pretest.pre_test() == "Pretest successfull")

当我运行py.test --collect-only时,运行测试用例而不是仅显示要运行的测试用例列表。

然后我面临的问题是,如果我运行py.test -v check_host.py,则测试用例pre_test运行两次;一次收集,再次在实际运行中。

0 个答案:

没有答案