-
Notifications
You must be signed in to change notification settings - Fork 244
ran testcases by multi-threads, then allure raised /usr/local/lib/python3.9/site-packages/allure_commons/reporter.py:33: KeyError #697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@ae86sen could you please provide code examples and how exactly you run tests by multi-threads? |
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? |
it seems to have something to do with the ”@allure.step“. 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() |
Hi, @ae86sen The thing is that we have two slightly different scenarios related to multithreading with allure:
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. |
thanks!Looking forward to your good news~ |
i ran testcases by multi-threads, then allure raised the error.

The text was updated successfully, but these errors were encountered: