mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-25 10:48:18 +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:
@@ -1,6 +1,5 @@
|
||||
import os.path
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from test.picardtestcase import PicardTestCase
|
||||
@@ -13,15 +12,10 @@ class Testbytes2human(PicardTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# we are using temporary locales for tests
|
||||
self.tmp_path = tempfile.mkdtemp()
|
||||
if sys.hexversion >= 0x020700F0:
|
||||
self.addCleanup(shutil.rmtree, self.tmp_path)
|
||||
self.tmp_path = tempfile.mkdtemp(suffix=self.__class__.__name__)
|
||||
self.addCleanup(shutil.rmtree, self.tmp_path)
|
||||
self.localedir = os.path.join(self.tmp_path, 'locale')
|
||||
|
||||
def tearDown(self):
|
||||
if sys.hexversion < 0x020700F0:
|
||||
shutil.rmtree(self.tmp_path)
|
||||
|
||||
def test_00(self):
|
||||
# testing with default C locale, english
|
||||
lang = 'C'
|
||||
|
||||
Reference in New Issue
Block a user