[Python] Keyerror in Allure Behave

Discussão em 'Python' iniciado por Stack, Maio 22, 2025.

  1. Stack

    Stack Membro Participativo

    Im currently trying to run an automation script using behave and generate reports using allure behave python.

    The code is working file if the allure reporting is not used.

    Exception KeyError:
    Traceback (most recent call last):
    File "/home/administrator/.local/bin/behave", line 8, in <module>
    sys.exit(main())
    File "/home/administrator/.local/lib/python3.10/site-packages/behave/__main__.py", line 183, in main
    return run_behave(config)
    File "/home/administrator/.local/lib/python3.10/site-packages/behave/__main__.py", line 127, in run_behave
    failed = runner.run()
    File "/home/administrator/.local/lib/python3.10/site-packages/behave/runner.py", line 804, in run
    return self.run_with_paths()
    File "/home/administrator/.local/lib/python3.10/site-packages/behave/runner.py", line 824, in run_with_paths
    return self.run_model()
    File "/home/administrator/.local/lib/python3.10/site-packages/behave/runner.py", line 626, in run_model
    failed = feature.run(self)
    File "/home/administrator/.local/lib/python3.10/site-packages/behave/model.py", line 321, in run
    failed = scenario.run(runner)
    File "/home/administrator/.local/lib/python3.10/site-packages/allure_commons/_allure.py", line 236, in __call__
    with self:
    File "/home/administrator/.local/lib/python3.10/site-packages/allure_commons/_allure.py", line 247, in __exit__
    plugin_manager.hook.stop_test(parent_uuid=None,
    File "/home/administrator/.local/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
    File "/home/administrator/.local/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
    File "/home/administrator/.local/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
    File "/home/administrator/.local/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
    File "/home/administrator/.local/lib/python3.10/site-packages/allure_behave/listener.py", line 99, in stop_test
    self.stop_scenario(context['scenario'])
    File "/home/administrator/.local/lib/python3.10/site-packages/allure_behave/listener.py", line 118, in stop_scenario
    self.logger.close_test(self.current_scenario_uuid)
    File "/home/administrator/.local/lib/python3.10/site-packages/allure_commons/reporter.py", line 120, in close_test
    test_case = self._items.pop(uuid)
    File "/home/administrator/.local/lib/python3.10/site-packages/allure_commons/reporter.py", line 45, in pop
    return self.thread_context.pop(key)
    KeyError


    I have tried multiple versions of the allure behave but still facing the same issue. I am getting this Keyerror at the of the of the first scenario in the feature file and the test case is showing as passed in the generated reports.

    Continue reading...

Compartilhe esta Página