55from allure_commons .utils import uuid4
66from allure_commons .utils import represent
77from allure_commons .utils import platform_label
8- from allure_commons .utils import host_tag , thread_tag
8+ from allure_commons .utils import host_tag , thread_tag , thread_tag_detail
99from allure_commons .reporter import AllureReporter
1010from allure_commons .model2 import TestStepResult , TestResult , TestBeforeResult , TestAfterResult
1111from allure_commons .model2 import TestResultContainer
2222from allure_pytest .utils import get_outcome_status , get_outcome_status_details
2323from allure_pytest .utils import get_pytest_report_status
2424from allure_commons .utils import md5
25- import threading
2625
2726
2827class AllureListener (object ):
@@ -37,13 +36,8 @@ def __init__(self, config):
3736 @allure_commons .hookimpl
3837 def start_step (self , uuid , title , params ):
3938 parameters = [Parameter (name = name , value = value ) for name , value in params .items ()]
40- step = TestStepResult (name = title , start = now (), parameters = parameters , thrd = threading .current_thread ().name )
41- if thread_tag () != self ._thread :
42- self .allure_logger .start_step (self .allure_logger .last_with_thread (), uuid , step )
43- else :
44- self .allure_logger .start_step (None , uuid , step )
45- # step = TestStepResult(name=title, start=now(), parameters=parameters)
46- # self.allure_logger.start_step(None, uuid, step)
39+ step = TestStepResult (name = title , start = now (), parameters = parameters , thrd = thread_tag_detail ())
40+ self .allure_logger .start_step (None , uuid , step )
4741
4842 @allure_commons .hookimpl
4943 def stop_step (self , uuid , exc_type , exc_val , exc_tb ):
@@ -54,7 +48,7 @@ def stop_step(self, uuid, exc_type, exc_val, exc_tb):
5448
5549 @allure_commons .hookimpl
5650 def start_fixture (self , parent_uuid , uuid , name ):
57- after_fixture = TestAfterResult (name = name , start = now ())
51+ after_fixture = TestAfterResult (name = name , start = now (), thrd = thread_tag_detail () )
5852 self .allure_logger .start_after_fixture (parent_uuid , uuid , after_fixture )
5953
6054 @allure_commons .hookimpl
@@ -67,15 +61,15 @@ def stop_fixture(self, parent_uuid, uuid, name, exc_type, exc_val, exc_tb):
6761 @pytest .hookimpl (hookwrapper = True , tryfirst = True )
6862 def pytest_runtest_protocol (self , item , nextitem ):
6963 uuid = self ._cache .push (item .nodeid )
70- test_result = TestResult (name = item .name , uuid = uuid , start = now (), stop = now ())
64+ test_result = TestResult (name = item .name , uuid = uuid , start = now (), stop = now (), thrd = thread_tag_detail () )
7165 self .allure_logger .schedule_test (uuid , test_result )
7266 yield
7367
7468 @pytest .hookimpl (hookwrapper = True )
7569 def pytest_runtest_setup (self , item ):
7670 if not self ._cache .get (item .nodeid ):
7771 uuid = self ._cache .push (item .nodeid )
78- test_result = TestResult (name = item .name , uuid = uuid , start = now (), stop = now ())
72+ test_result = TestResult (name = item .name , uuid = uuid , start = now (), stop = now (), thrd = thread_tag_detail () )
7973 self .allure_logger .schedule_test (uuid , test_result )
8074
8175 yield
@@ -86,7 +80,7 @@ def pytest_runtest_setup(self, item):
8680 group_uuid = self ._cache .get (fixturedef )
8781 if not group_uuid :
8882 group_uuid = self ._cache .push (fixturedef )
89- group = TestResultContainer (uuid = group_uuid )
83+ group = TestResultContainer (uuid = group_uuid , thrd = thread_tag_detail () )
9084 self .allure_logger .start_group (group_uuid , group )
9185 self .allure_logger .update_group (group_uuid , children = uuid )
9286 params = item .callspec .params if hasattr (item , 'callspec' ) else {}
@@ -134,13 +128,13 @@ def pytest_fixture_setup(self, fixturedef, request):
134128
135129 if not container_uuid :
136130 container_uuid = self ._cache .push (fixturedef )
137- container = TestResultContainer (uuid = container_uuid )
131+ container = TestResultContainer (uuid = container_uuid , thrd = thread_tag_detail () )
138132 self .allure_logger .start_group (container_uuid , container )
139133
140134 self .allure_logger .update_group (container_uuid , start = now ())
141135
142136 before_fixture_uuid = uuid4 ()
143- before_fixture = TestBeforeResult (name = fixture_name , start = now ())
137+ before_fixture = TestBeforeResult (name = fixture_name , start = now (), thrd = thread_tag_detail () )
144138 self .allure_logger .start_before_fixture (container_uuid , before_fixture_uuid , before_fixture )
145139
146140 outcome = yield
@@ -247,12 +241,6 @@ def add_description_html(self, test_description_html):
247241 if test_result :
248242 test_result .descriptionHtml = test_description_html
249243
250- @allure_commons .hookimpl
251- def add_thrd (self , test_description_html ):
252- test_result = self .allure_logger .get_test (None )
253- if test_result :
254- test_result .descriptionHtml = test_description_html
255-
256244 @allure_commons .hookimpl
257245 def add_link (self , url , link_type , name ):
258246 test_result = self .allure_logger .get_test (None )
0 commit comments