From a5bc43e34c301232571708615f8b8d78cb56a36d Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Tue, 28 Jul 2026 12:51:52 +0500 Subject: [PATCH] Don't generate test keys concurrently with xdist. (#7792) --- conftest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conftest.py b/conftest.py index b8a9dc19e..27c398792 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,6 @@ from __future__ import annotations +import os from importlib.util import find_spec from pathlib import Path from typing import TYPE_CHECKING @@ -135,5 +136,6 @@ def pytest_runtest_setup(item): pytest.skip("mitmdump is not available") -# Generate localhost certificate files, needed by some tests -generate_keys() +# Generate localhost certificate files, needed by some tests (but only once if xdist is used) +if "PYTEST_XDIST_WORKER" not in os.environ: + generate_keys()