GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ran testcases by multi-threads, then allure raised /usr/local/lib/python3.9/site-packages/allure_commons/reporter.py:33: KeyError · Issue #697 · allure-framework/allure-python

ran testcases by multi-threads, then allure raised /usr/local/lib/python3.9/site-packages/allure_commons/reporter.py:33: KeyError #697

New issue
Copy link
New issue
Copy link
Open
Bug
Open
ran testcases by multi-threads, then allure raised /usr/local/lib/python3.9/site-packages/allure_commons/reporter.py:33: KeyError#697
Bug
Copy link
Labels
bugSomething isn't workingSomething isn't workingtheme:coretheme:pytest

Description

@ae86sen
ae86sen
opened on Oct 12, 2022
Issue body actions

i ran testcases by multi-threads, then allure raised the error.
image

version:
python: 3.9.13
allure: 2.14.0
allure-pytest: 2.10.0
pytest: 7.1.2

Activity

  1. skhomuti commented on Oct 12, 2022

    @skhomuti
    skhomuti
    on Oct 12, 2022
    Contributor
    More actions

    @ae86sen could you please provide code examples and how exactly you run tests by multi-threads?

  2. ae86sen commented on Nov 28, 2022

    @ae86sen
    ae86sen
    on Nov 28, 2022
    Author
    More actions

    @ae86sen 你能不能提供代码例子,以及你到底是如何通过多线程运行测试的?

    run.py

    import pytest from concurrent.futures 
    import ThreadPoolExecutor, wait, ALL_COMPLETED
    
    
    def main_task(args: list): 
        ""pytest"" 
        pytest.main(args)
    
    if __name__ == '__main__': 
        marks = ['-m hpc', '-m ehpc'] 
        thread_count = len(mark) tp = ThreadPoolExecutor(max_workers=thread_count)
        _ = [tp.submit(main_task, arg) for arg in marks] 
        wait(_, return_when=ALL_COMPLETED) 
        tp.shutdown()

    testcase_demo.py

    @pytest.mark.hpc 
    def test_hpc(): 
        pass
    
    @pytest.mark.ehpc
     def test_hpc(): 
        pass

    It doesn't have to raised “keyerror” ,but i haven't found the necessary conditions,It seems to be related to the thread isolation of allure?

  3. delatrie
    added
    bugSomething isn't workingSomething isn't working
    theme:pytest
    on Dec 2, 2022
  4. ae86sen commented on Dec 5, 2022

    @ae86sen
    ae86sen
    on Dec 5, 2022
    Author
    More actions

    it seems to have something to do with the ”@allure.step“.
    there is a new code example:
    test_demo.py

    import time
    
    import allure
    import pytest
    
    
    @allure.title("hello")
    @pytest.mark.d1
    @allure.step('123')
    def test_hpc():
        time.sleep(1)
    
    @allure.title("hello")
    @pytest.mark.d2
    @allure.step('123')
    def test_hpc2():
        time.sleep(1)
    
    @allure.title("hello")
    @pytest.mark.d3
    @allure.step('123')
    def test_hpc3():
        time.sleep(1)
    
    
    @allure.title("hello")
    @pytest.mark.d4
    @allure.step('123')
    def test_hpc4():
        time.sleep(1)

    run.py

    from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED
    
    import pytest
    
    
    def main_task(args: str):
        params = ["-s", "--alluredir=report"]
        params.append(args)
        print(params)
        pytest.main(params)
    
    
    def main():
        marks = ["-m d1", "-m d2", "-m d3", "-m d4"]
        tp = ThreadPoolExecutor(max_workers=len(marks))
        _ = [tp.submit(main_task, m) for m in marks]
        wait(_, return_when=ALL_COMPLETED)
        tp.shutdown()
    
    
    if __name__ == '__main__':
        main()

    when i ran run.py, raised the error:
    image
    image

  5. ae86sen commented on Dec 5, 2022

    @ae86sen
    ae86sen
    on Dec 5, 2022
    Author
    More actions

    i tried to run with v2.8.24 of allure-pytest, it's no problem.
    image

  6. ae86sen commented on Dec 5, 2022

    @ae86sen
    ae86sen
    on Dec 5, 2022
    Author
    More actions

    image

  7. delatrie commented on Dec 5, 2022

    @delatrie
    delatrie
    on Dec 5, 2022
    Contributor
    More actions

    Hi, @ae86sen
    Thanks for complete examples and highlights.

    The thing is that we have two slightly different scenarios related to multithreading with allure:

    1. Running tests concurrently in a multithreaded environment (your scenario)
    2. Running steps concurrently inside a test (see Allure step in thread not show in report. #563)

    The changes you are referring to were introduced to deal with (2).

    I'll take a look on how to add support for (1). We also have issue with an async concurrency that needs to be addressed as well.

    As for now, I advise you (if possible) to utilize xdist, i.e. to use parallel execution in separated processes instead of running tests concurrently in multiple threads. If you don't need to share a common state across your tests that should do the job.

  8. ae86sen commented on Dec 6, 2022

    @ae86sen
    ae86sen
    on Dec 6, 2022
    Author
    More actions

    thanks!Looking forward to your good news~

  9. delatrie
    added
    theme:core
    on Jan 20, 2023
  10. delatrie
    added
    priority:major
    on Jun 20, 2023
  11. delatrie
    removed
    priority:major
    on Jul 8, 2023
  12. delatrie
    added the
    Bug
    issue type on Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't workingtheme:coretheme:pytest

    Type

    Bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.