Commit e83640d
pytester: avoid unraisableexception gc collects in inline runs to speed up test suite
Because `pytester.runpytest()` executes the full session cycle (including
`pytest_unconfigure`), it was calling `gc.collect()` in a loop multiple
times—even for small, fast tests. This significantly increased the total
test suite runtime.
To optimize performance, disable the gc runs in inline pytester runs
entirely, matching the behavior before pytest-dev#12958.
Locally the test suite runtime improved dramatically, dropping from 425s
to 160s.
Fixes pytest-dev#13482.
Co-authored-by: Bruno Oliveira <[email protected]>1 parent 336cb91 commit e83640d
File tree
3 files changed
+40
-24
lines changed- src/_pytest
- testing
3 files changed
+40
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
1115 | 1116 | | |
1116 | 1117 | | |
1117 | 1118 | | |
1118 | | - | |
| 1119 | + | |
1119 | 1120 | | |
1120 | 1121 | | |
1121 | 1122 | | |
1122 | 1123 | | |
1123 | | - | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
1124 | 1129 | | |
1125 | 1130 | | |
1126 | 1131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
87 | 92 | | |
88 | 93 | | |
89 | | - | |
| 94 | + | |
90 | 95 | | |
91 | 96 | | |
92 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
245 | 248 | | |
246 | 249 | | |
247 | 250 | | |
| |||
256 | 259 | | |
257 | 260 | | |
258 | 261 | | |
259 | | - | |
260 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
261 | 265 | | |
262 | | - | |
263 | | - | |
| 266 | + | |
264 | 267 | | |
265 | 268 | | |
266 | 269 | | |
267 | 270 | | |
268 | 271 | | |
269 | | - | |
270 | 272 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | 273 | | |
275 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
276 | 278 | | |
277 | 279 | | |
278 | 280 | | |
| |||
287 | 289 | | |
288 | 290 | | |
289 | 291 | | |
290 | | - | |
291 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
292 | 295 | | |
293 | | - | |
294 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
295 | 299 | | |
296 | 300 | | |
297 | 301 | | |
298 | 302 | | |
299 | 303 | | |
300 | | - | |
301 | 304 | | |
302 | 305 | | |
303 | 306 | | |
| |||
306 | 309 | | |
307 | 310 | | |
308 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
309 | 315 | | |
310 | 316 | | |
311 | 317 | | |
| |||
318 | 324 | | |
319 | 325 | | |
320 | 326 | | |
321 | | - | |
322 | | - | |
| 327 | + | |
323 | 328 | | |
324 | | - | |
325 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
326 | 332 | | |
327 | 333 | | |
328 | 334 | | |
| |||
0 commit comments