Skip to content

Avoid live-log verbosity changes in sessions without local tests - #15176

Open
starx710 wants to merge 1 commit into
pytest-dev:mainfrom
starx710:fix-xdist-live-log-verbosity-1249
Open

starx710 wants to merge 1 commit into
pytest-dev:mainfrom
starx710:fix-xdist-live-log-verbosity-1249

Conversation

@starx710

@starx710 starx710 commented Oct 14, 2026 •

Copy link
Copy Markdown

When log_cli=true or --log-cli-level enables live logging, a pytest-xdist controller raises the global verbosity to 1 even though it runs no tests locally. Default progress becomes per-test verbose output, and -q / -qq lose their intended behavior.

Require local session items before promoting verbosity in the logging plugin's pytest_runtestloop wrapper. The controller keeps the requested progress verbosity, while serial runs, -n0, and --dist=no retain their existing live-log presentation. Log handlers, controller hook logging, file logging, and worker caplog capture remain active. This adds no dependency on xdist internals and does not implement forwarding worker live logs.

Fixes pytest-dev/pytest-xdist#1249. Related: #14667 changes CLI-enabled serial live-log presentation; this change is limited to sessions without local items and preserves serial behavior for both configuration and CLI logging options.

Regression tests use real pytest sessions and worker subprocesses. They cover default/quiet/verbose output, log_cli and --log-cli-level, one and two workers, explicit --tx, serial execution modes, and hook/file logging without local items.

Validation on Windows / CPython 3.12.10, with pytest-xdist 3.8.0, execnet 2.1.2, and Pluggy 1.6.0:

  • Final added regressions against isolated, unchanged upstream source: 14 failed, 10 passed. All 24 pass with this patch.
  • Entire testing/logging directory: 115 passed.
  • Full suite on commit f81686c: 4631 passed, 142 skipped, 13 xfailed, 1 non-strict xpassed, 1 failed. The failure is testing/test_parseopt.py::test_argcomplete: the machine's Windows System32 Bash output raises a GBK decoding error. The unchanged upstream source fails at the same subprocess read; no tests were modified or deselected to avoid it.
  • All standard pre-commit run --all-files --show-diff-on-failure hooks passed, including Ruff, mypy, zizmor, and codespell. Hooks configured for manual invocation were not run.
  • Towncrier draft and git diff --check passed.

Source base: c9c19f8. Local editable-build version metadata was set to 9.2.0.dev0 via setuptools-scm's standard override because the shallow clone lacks tag ancestry; source identity and before/after comparisons use commit SHAs. Other platforms and Python versions have not been tested locally.

AI assistance: OpenAI Codex prepared the patch, tests, and local validation notes.

Keep controller progress at the requested verbosity while retaining serial
live logging. Refs pytest-dev/pytest-xdist#1249.

Co-authored-by: OpenAI Codex <noreply@openai.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] log_cli unexpectedly causes verbose progress output

1 participant