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 件 担当者 0 名 GitHub で見る
bug theme:behave
主要言語
Python
スター
814
フォーク
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 を短くまとめたダイジェスト。