要求:
我有一个测试,该测试与外部设备对话,然后检索设备输出。测试需要处理此输出,然后根据单个测试中的返回日志多次生成pytest结果(通过/失败/跳过)。
例如:
def test_run_device_tests():
output_log = run_device_tests(cmd)
for line in output_log:
if "PASS" in line:
# pass a pytest with a specific value as test name
elif "FAIL" in line:
# fail a pytest with a specific value as test name
# and continue with the remaining parsing
我已经考虑过使用“ pytest_generate_tests”。但是我看不到如何将其用作“ cmd”来获取output_log。