Commit 606a268
Fix terminal reporter output not appearing with capture active
Fixes #8973
When calling `reporter.write()` with `flush=True` during test execution,
the output was not appearing in the terminal because pytest's output
capture system intercepts writes to sys.stdout.
This fix duplicates stdout's file descriptor early in `_prepareconfig()`,
before any capture can start, and stores it in the config stash. The
terminal reporter then uses this duplicated FD to write directly to the
real terminal, bypassing capture.
The duplicated file is opened with line buffering and write_through mode
to ensure immediate visibility of output.
Changes:
- src/_pytest/config/__init__.py: Add stdout FD duplication and stash key
- src/_pytest/terminal.py: Use duplicated FD in pytest_configure
- testing/test_terminal.py: Add regression test and fix incompatible tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 8209647 commit 606a268
File tree
3 files changed
+118
-10
lines changed- src/_pytest
- config
- testing
3 files changed
+118
-10
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 | | |
71 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
| |||
327 | 334 | | |
328 | 335 | | |
329 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
330 | 349 | | |
331 | 350 | | |
332 | 351 | | |
| |||
336 | 355 | | |
337 | 356 | | |
338 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
339 | 364 | | |
340 | 365 | | |
341 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
289 | 315 | | |
290 | 316 | | |
291 | 317 | | |
| |||
394 | 420 | | |
395 | 421 | | |
396 | 422 | | |
| 423 | + | |
| 424 | + | |
397 | 425 | | |
398 | 426 | | |
399 | 427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
3418 | 3417 | | |
3419 | 3418 | | |
3420 | 3419 | | |
3421 | | - | |
3422 | | - | |
3423 | | - | |
3424 | | - | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
| 3423 | + | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
| 3432 | + | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + | |
| 3438 | + | |
| 3439 | + | |
| 3440 | + | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
3425 | 3445 | | |
3426 | 3446 | | |
3427 | 3447 | | |
3428 | | - | |
3429 | | - | |
3430 | | - | |
3431 | | - | |
| 3448 | + | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
3432 | 3465 | | |
3433 | 3466 | | |
3434 | 3467 | | |
| |||
3508 | 3541 | | |
3509 | 3542 | | |
3510 | 3543 | | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
0 commit comments