We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 08d0dd0 commit a6f85a0Copy full SHA for a6f85a0
changelog/10607.bugfix.rst
@@ -0,0 +1 @@
1
+Fix a race condition when creating junitxml reports, which could occur when multiple instances of pytest execute in parallel.
src/_pytest/junitxml.py
@@ -645,8 +645,8 @@ def pytest_sessionstart(self) -> None:
645
646
def pytest_sessionfinish(self) -> None:
647
dirname = os.path.dirname(os.path.abspath(self.logfile))
648
- if not os.path.isdir(dirname):
649
- os.makedirs(dirname)
+ # exist_ok avoids filesystem race conditions between checking path existence and requesting creation
+ os.makedirs(dirname, exist_ok=True)
650
651
with open(self.logfile, "w", encoding="utf-8") as logfile:
652
suite_stop_time = timing.time()
0 commit comments