我有一个环境需要使用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
运行两次;一次收集,再次在实际运行中。