mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
DRYer
This commit is contained in:
parent
76381f5cdd
commit
e7d6101bd4
3 changed files with 10 additions and 7 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue