Log the number of xdist workers in pytest runs (#183682)

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
Erwin Douna
2026-09-30 11:42:47 +02:00
committed by GitHub
co-authored by epenet
parent 88df866494
commit 30ab7eb20a
+11 -1
View File
@@ -1,7 +1,7 @@
"""Set up some common test helper things."""
import asyncio
from collections.abc import AsyncGenerator, Callable, Coroutine, Generator
from collections.abc import AsyncGenerator, Callable, Coroutine, Generator, Sequence
from contextlib import AsyncExitStack, asynccontextmanager, contextmanager
import datetime
import functools
@@ -33,6 +33,7 @@ from aiohttp.typedefs import JSONDecoder
from aiohttp.web import Application
import bcrypt
from bleak_retry_connector import bleak_manager
import execnet
import freezegun
import multidict
import pytest
@@ -177,6 +178,15 @@ def pytest_configure(config: pytest.Config) -> None:
logging.getLogger().setLevel(logging.DEBUG)
@pytest.hookimpl(optionalhook=True)
def pytest_xdist_setupnodes(
config: pytest.Config, specs: Sequence[execnet.XSpec]
) -> None:
"""Log the number of xdist workers, also when running with -qq."""
if reporter := config.pluginmanager.get_plugin("terminalreporter"):
reporter.write_line(f"xdist workers: {len(specs)}")
class HASocketBlockedError(pytest_socket.SocketBlockedError):
"""SocketBlockedError variant which counts instances."""