mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-27 11:47:34 +00:00
Tests: ensure temporary directories and files are removed after tests
- QSettings object needs special care, as file was re-created on exit - Append a cleanup function as soon as possible to ensure temporary dirs & files are removed in any case - prefer addCleanup() over tearDown(), keeping creation and cleanup together
This commit is contained in:
@@ -22,14 +22,12 @@ class TestFileSystem(PicardTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.src_directory = mkdtemp()
|
||||
self.src_directory = mkdtemp(suffix=self.__class__.__name__)
|
||||
self.addCleanup(shutil.rmtree, self.src_directory)
|
||||
self.tgt_directory = mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, self.tgt_directory)
|
||||
config.setting = settings.copy()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.src_directory)
|
||||
shutil.rmtree(self.tgt_directory)
|
||||
|
||||
def _prepare_files(self, src_rel_path='', tgt_rel_path=''):
|
||||
"""Prepare src files and tgt filenames for a test."""
|
||||
with suppress(FileExistsError):
|
||||
|
||||
Reference in New Issue
Block a user