@@ -58,6 +58,19 @@ def stop_fixture(self, parent_uuid, uuid, name, exc_type, exc_val, exc_tb):
58
58
status = get_status (exc_val ),
59
59
statusDetails = get_status_details (exc_type , exc_val , exc_tb ))
60
60
61
+ def _update_fixtures_children (self , item ):
62
+ uuid = self ._cache .get (item .nodeid )
63
+ for fixturedef in _test_fixtures (item ):
64
+ group_uuid = self ._cache .get (fixturedef )
65
+ if group_uuid :
66
+ group = self .allure_logger .get_item (group_uuid )
67
+ else :
68
+ group_uuid = self ._cache .push (fixturedef )
69
+ group = TestResultContainer (uuid = group_uuid )
70
+ self .allure_logger .start_group (group_uuid , group )
71
+ if uuid not in group .children :
72
+ self .allure_logger .update_group (group_uuid , children = uuid )
73
+
61
74
@pytest .hookimpl (hookwrapper = True , tryfirst = True )
62
75
def pytest_runtest_protocol (self , item , nextitem ):
63
76
uuid = self ._cache .push (item .nodeid )
@@ -71,20 +84,11 @@ def pytest_runtest_setup(self, item):
71
84
uuid = self ._cache .push (item .nodeid )
72
85
test_result = TestResult (name = item .name , uuid = uuid , start = now (), stop = now ())
73
86
self .allure_logger .schedule_test (uuid , test_result )
74
-
75
87
yield
76
-
88
+ self . _update_fixtures_children ( item )
77
89
uuid = self ._cache .get (item .nodeid )
78
90
test_result = self .allure_logger .get_test (uuid )
79
- for fixturedef in _test_fixtures (item ):
80
- group_uuid = self ._cache .get (fixturedef )
81
- if not group_uuid :
82
- group_uuid = self ._cache .push (fixturedef )
83
- group = TestResultContainer (uuid = group_uuid )
84
- self .allure_logger .start_group (group_uuid , group )
85
- self .allure_logger .update_group (group_uuid , children = uuid )
86
91
params = item .callspec .params if hasattr (item , 'callspec' ) else {}
87
-
88
92
test_result .name = allure_name (item , params )
89
93
full_name = allure_full_name (item )
90
94
test_result .fullName = full_name
@@ -104,12 +108,14 @@ def pytest_runtest_call(self, item):
104
108
self .allure_logger .schedule_test (uuid , test_result )
105
109
test_result .start = now ()
106
110
yield
111
+ self ._update_fixtures_children (item )
107
112
if test_result :
108
113
test_result .stop = now ()
109
114
110
115
@pytest .hookimpl (hookwrapper = True )
111
116
def pytest_runtest_teardown (self , item ):
112
117
yield
118
+ self ._update_fixtures_children (item )
113
119
uuid = self ._cache .get (item .nodeid )
114
120
test_result = self .allure_logger .get_test (uuid )
115
121
test_result .labels .extend ([Label (name = name , value = value ) for name , value in allure_labels (item )])
@@ -132,7 +138,6 @@ def pytest_fixture_setup(self, fixturedef, request):
132
138
container_uuid = self ._cache .push (fixturedef )
133
139
container = TestResultContainer (uuid = container_uuid )
134
140
self .allure_logger .start_group (container_uuid , container )
135
- self .allure_logger .update_group (container_uuid , children = self ._cache .get (request ._pyfuncitem .nodeid ))
136
141
137
142
self .allure_logger .update_group (container_uuid , start = now ())
138
143
0 commit comments