mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-31 13:48:01 +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:
@@ -43,13 +43,11 @@ class TestPreserveTimes(PicardTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.tmp_directory = mkdtemp()
|
||||
self.tmp_directory = mkdtemp(suffix=self.__class__.__name__)
|
||||
self.addCleanup(shutil.rmtree, self.tmp_directory)
|
||||
filepath = os.path.join(self.tmp_directory, 'a.mp3')
|
||||
self.file = File(filepath)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmp_directory)
|
||||
|
||||
def _create_testfile(self):
|
||||
# create a dummy file
|
||||
with open(self.file.filename, 'w') as f:
|
||||
|
||||
Reference in New Issue
Block a user