我有我的 pytest-bdd 钩子
def pytest_bdd_step_error(request, feature, scenario, step, step_func, step_func_args, exception):
"""Print step number which is failed."""
if scenario == "env_availability":
send_teams_msg_env_channel(f"Step failed: {step}")
else:
send_teams_msg(f"Step failed: {step}")
print(f"Step failed: {step}")
我的愿望是运行名为“env_availability”的场景,当它无法将按摩发送到团队的一个频道时,对于其他场景,我有其他频道。我尝试了很多解决方案,唯一的想法是我得到的是代码,否则找不到解决方案如何解决这个问题:
if scenario == "env_availability":
如果我打印场景,我会得到结果:
<pytest_bdd.parser.Scenario object at 0x000001E0BDB25520>
这是我的场景`功能:环境可用性
Feature: env availability
Scenario: env availability
Given Web browser is opened on login page on QA