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,