From ebf8761cb7df73c01cf9a1176429f9b95f3f29d3 Mon Sep 17 00:00:00 2001 From: Yusuke Kadowaki Date: Thu, 27 Oct 2022 01:16:43 +0900 Subject: [PATCH] Add cleanup dead symlink --- src/_pytest/pathlib.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 74d60b83a..b2605430c 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -346,6 +346,12 @@ def cleanup_numbered_dir( for path in root.glob("garbage-*"): try_cleanup(path, consider_lock_dead_if_created_before) + # remove dead symlink + for left_dir in root.iterdir(): + if left_dir.is_symlink(): + if not left_dir.resolve().exists(): + left_dir.unlink() + def make_numbered_dir_with_cleanup( root: Path,