Skip to content

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

Open
@lyfofvipin

Description

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]$

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions