From e5f87af9c4d2e2715bb8ed4b19662eaf2090341a Mon Sep 17 00:00:00 2001 From: Kadino Date: Fri, 23 Dec 2022 22:07:48 -0800 Subject: [PATCH] Update junitxml.py --- src/_pytest/junitxml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index b99306ce9..9242d46d9 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -645,8 +645,8 @@ class LogXML: def pytest_sessionfinish(self) -> None: dirname = os.path.dirname(os.path.abspath(self.logfile)) - if not os.path.isdir(dirname): - os.makedirs(dirname, exist_ok=True) + # exist_ok avoids filesystem race conditions between checking path existence and requesting creation + os.makedirs(dirname, exist_ok=True) with open(self.logfile, "w", encoding="utf-8") as logfile: suite_stop_time = timing.time()