diff --git a/kitty_tests/__init__.py b/kitty_tests/__init__.py index e45994884..8716f465e 100644 --- a/kitty_tests/__init__.py +++ b/kitty_tests/__init__.py @@ -6,6 +6,7 @@ import io import os import select import shlex +import shutil import signal import struct import sys @@ -179,6 +180,12 @@ class BaseTest(TestCase): maxDiff = 2048 is_ci = os.environ.get('CI') == 'true' + def rmtree_ignoring_errors(self, tdir): + try: + shutil.rmtree(tdir) + except FileNotFoundError as err: + print('Failed to delete the directory:', tdir, 'with error:', err, file=sys.stderr) + def tearDown(self): set_options(None) diff --git a/kitty_tests/file_transmission.py b/kitty_tests/file_transmission.py index 80f28081b..a96ed4177 100644 --- a/kitty_tests/file_transmission.py +++ b/kitty_tests/file_transmission.py @@ -7,7 +7,7 @@ import shutil import stat import tempfile from collections import namedtuple -from contextlib import contextmanager, suppress +from contextlib import contextmanager from pathlib import Path from kittens.transfer.rsync import Differ, Hasher, Patcher, parse_ftc @@ -188,8 +188,7 @@ class TestFileTransmission(BaseTest): self.orig_home = os.environ.get('HOME') def tearDown(self): - with suppress(FileNotFoundError): - shutil.rmtree(self.tdir) + self.rmtree_ignoring_errors(self.tdir) self.responses = [] if self.orig_home is None: os.environ.pop('HOME', None) diff --git a/kitty_tests/fonts.py b/kitty_tests/fonts.py index e5184c474..ed8cd5d55 100644 --- a/kitty_tests/fonts.py +++ b/kitty_tests/fonts.py @@ -2,11 +2,9 @@ # License: GPL v3 Copyright: 2017, Kovid Goyal import os -import shutil import sys import tempfile import unittest -from contextlib import suppress from functools import partial from kitty.constants import is_macos, read_kitty_resource @@ -35,8 +33,7 @@ class Rendering(BaseTest): def tearDown(self): self.test_ctx.__exit__() del self.sprites, self.cell_width, self.cell_height, self.test_ctx - with suppress(FileNotFoundError): - shutil.rmtree(self.tdir) + self.rmtree_ignoring_errors(self.tdir) super().tearDown() def test_sprite_map(self):