allure-framework / allure-framework/allure-python

Getting `HOOK-ERROR in after_step` if `context.execute_steps` used in any step of Behave Scenario.

未关闭
#584 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug theme:behave
主要语言
Python
星标
815
派生
260
PR 合并指标
30 天内没有已合并 PR

描述

#### I'm submitting a ...
bug report

#### What is the current behavior?
When ever I am using the plugin and executing behave tests I am getting error `HOOK-ERROR in after_step: KeyError:` everytime If any step of the Scenario is using method `context.execute_steps`.

#### If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
Yes above behavior is a bug,
How to reproduce the issue:
I am putting my directory structure:
```
features/
├── environment.py
├── steps
│   └── fir.py
└── test
└── first.feature

2 directories, 3 files
```
Here content of `first.feature` file
```
Feature: Learn Behave

Scenario: Testing diffrent data transfer
Given Simple function "value of xyz"
```
Content of `fir.py`
```
from behave import Given, When, Then
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

@Given("Simple function {xyz}")
def simp(context, xyz):
context.execute_steps(u"""
given test func 2
""")
assert True

@Given("test func 2")
def text(context):
assert True
```
Content of `environment.py`
```
from allure_behave.hooks import allure_report
allure_report()
```
And when I try to run my feature file I am getting error `HOOK-ERROR in after_step: KeyError: 'some uuid'`

#### What is the expected behavior?
Behave tests should work fine.

#### Please tell us about your environment:

- Allure version: 2.8.40
- Test framework: behave 1.2.6
- Python: Python 3.8.7

#### Other information

Output and command I am running
```
(test) [vipikuma@kvy my_behave_project]$ behave features/test/first.feature -v --no-color
Using defaults:
color True
show_snippets True
show_skipped True
dry_run False
show_source True
show_timings True
stdout_capture True
stderr_capture True
log_capture True
logging_format %(levelname)s:%(name)s:%(message)s
logging_level 20
steps_catalog False
summary True
junit False
stage None
userdata {}
default_format pretty
default_tags
scenario_outline_annotation_schema {name} -- @{row.id} {examples.name}
Supplied path: "features/test/first.feature"
Primary path is to a file so using its directory
Trying base directory: /home/vipikuma/work_stuff/my_behave_project/features/test
Trying base directory: /home/vipikuma/work_stuff/my_behave_project/features
Using defaults:
color True
show_snippets True
show_skipped True
dry_run False
show_source True
show_timings True
stdout_capture True
stderr_capture True
log_capture True
logging_format %(levelname)s:%(name)s:%(message)s
logging_level 20
steps_catalog False
summary True
junit False
stage None
userdata {}
default_format pretty
default_tags
scenario_outline_annotation_schema {name} -- @{row.id} {examples.name}
Feature: Learn Behave # features/test/first.feature:1

Scenario: Testing diffrent data transfer # features/test/first.feature:3
Given Simple function "value of xyz" # features/steps/fir.py:6
Captured stdout:
HOOK-ERROR in after_step: KeyError: '7fac0091-918a-4de2-84e9-22defb2eb31a'
File "/home/vipikuma/work_stuff/my_behave_project/test/lib64/python3.8/site-packages/behave/runner.py", line 545, in run_hook
self.hooks[name](context, *args)
File "/home/vipikuma/work_stuff/my_behave_project/test/lib64/python3.8/site-packages/allure_behave/hooks.py", line 68, in after_step
self.listener.stop_behave_step(step)
File "/home/vipikuma/work_stuff/my_behave_project/test/lib64/python3.8/site-packages/allure_behave/listener.py", line 168, in stop_behave_step
self.logger.stop_step(self.current_step_uuid, stop=now(), status=status, statusDetails=status_details)
File "/home/vipikuma/work_stuff/my_behave_project/test/lib64/python3.8/site-packages/allure_commons/reporter.py", line 93, in stop_step
self._update_item(uuid, **kwargs)
File "/home/vipikuma/work_stuff/my_behave_project/test/lib64/python3.8/site-packages/allure_commons/reporter.py", line 17, in _update_item
item = self._items[uuid] if uuid else self._items[next(reversed(self._items))]

Failing scenarios:
features/test/first.feature:3 Testing diffrent data transfer

0 features passed, 1 failed, 0 skipped
0 scenarios passed, 1 failed, 0 skipped
0 steps passed, 1 failed, 0 skipped, 0 undefined
Took 0m0.000s
(test) [vipikuma@kvy my_behave_project]$
```

贡献指南

打开贡献指南

调研方向

使用报告中的 Behave 命令,通过 features/test/first.feature、features/steps/fir.py 和 environment.py 重现失败。阅读 after_step 路径上的 allure_behave/hooks.py 和 listener.py,然后验证使用 context.execute_steps 的场景能够在没有 HOOK-ERROR 的情况下完成,并且报告成功。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
testing
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。