@@ -51,6 +51,7 @@ def _generate_report(self, self_contained=False):
51
51
generated .strftime ("%H:%M:%S" ),
52
52
__version__ ,
53
53
self .css ,
54
+ run_count = self ._run_count (),
54
55
self_contained = self_contained ,
55
56
outcomes = self ._report .data ["outcomes" ],
56
57
test_data = cleanup_unserializable (self ._report .data ),
@@ -123,6 +124,7 @@ def _render_html(
123
124
time ,
124
125
version ,
125
126
styles ,
127
+ run_count ,
126
128
self_contained ,
127
129
outcomes ,
128
130
test_data ,
@@ -136,6 +138,7 @@ def _render_html(
136
138
time = time ,
137
139
version = version ,
138
140
styles = styles ,
141
+ run_count = run_count ,
139
142
self_contained = self_contained ,
140
143
outcomes = outcomes ,
141
144
test_data = json .dumps (test_data ),
@@ -149,6 +152,24 @@ def _write_report(self, rendered_report):
149
152
with self ._report_path .open ("w" , encoding = "utf-8" ) as f :
150
153
f .write (rendered_report )
151
154
155
+ def _run_count (self ):
156
+ data = self ._report .data
157
+ relevant_outcomes = ["passed" , "failed" , "xpassed" , "xfailed" ]
158
+ counts = 0
159
+ for outcome in data ["outcomes" ].keys ():
160
+ if outcome in relevant_outcomes :
161
+ counts += data ["outcomes" ][outcome ]["value" ]
162
+
163
+ plural = counts > 1
164
+ duration = _format_duration (data ["totalDuration" ])
165
+
166
+ if data ["runningState" ].lower () == "finished" :
167
+ return f"{ counts } { 'tests' if plural else 'test' } took { duration } ."
168
+
169
+ return (
170
+ f"{ counts } /{ data ['collectedItems' ]} { 'tests' if plural else 'test' } done."
171
+ )
172
+
152
173
@pytest .hookimpl (trylast = True )
153
174
def pytest_sessionstart (self , session ):
154
175
self ._report .set_data ("environment" , self ._generate_environment (metadata_key ))
@@ -197,10 +218,7 @@ def pytest_runtest_logreport(self, report):
197
218
"result" : outcome ,
198
219
"duration" : _format_duration (report .duration ),
199
220
}
200
-
201
- total_duration = self ._report .data ["totalDuration" ]
202
- total_duration ["total" ] += report .duration
203
- total_duration ["formatted" ] = _format_duration (total_duration ["total" ])
221
+ self ._report .data ["totalDuration" ] += report .duration
204
222
205
223
test_id = report .nodeid
206
224
if report .when != "call" :
0 commit comments