Make deleting test dir suring shell integration tests robust against fish 4 background daemon generating completions

This commit is contained in:
Kovid Goyal 2025-03-08 10:41:11 +05:30
parent 54e1f639a8
commit 8cbdd003e2
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -2,6 +2,7 @@
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
import errno
import os
import shlex
import shutil
@ -101,8 +102,15 @@ def run_shell(self, shell='zsh', rc='', cmd='', setup_env=None):
i -= 1
yield pty
finally:
if os.path.exists(home_dir):
shutil.rmtree(home_dir)
while os.path.exists(home_dir):
try:
shutil.rmtree(home_dir)
except OSError as e:
# As of fish 4 fish runs a background daemon generating
# completions.
if e.errno == errno.ENOTEMPTY:
continue
raise
@unittest.skipUnless(shutil.which('zsh'), 'zsh not installed')
def test_zsh_integration(self):