Add retries around other db removals

This commit is contained in:
Raoul Snyman 2016-01-15 21:14:24 +02:00
parent 1e8d787b93
commit 48eeb50d02
3 changed files with 19 additions and 8 deletions

View File

@ -87,8 +87,6 @@ class TestProjectorDB(TestCase):
Set up anything necessary for all tests
"""
with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
if os.path.exists(TEST_DB):
os.unlink(TEST_DB)
mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB
self.projector = ProjectorDB()
@ -98,6 +96,14 @@ class TestProjectorDB(TestCase):
"""
self.projector.session.close()
self.projector = None
while retries < 5:
try:
if os.path.exists(TEST_DB):
os.unlink(TEST_DB)
break
except:
time.sleep(1)
retries += 1
def find_record_by_ip_test(self):
"""

View File

@ -60,13 +60,12 @@ class TestUtilsDBFunctions(TestCase):
retries = 0
while retries < 5:
try:
shutil.rmtree(self.tmp_folder)
# os.unlink(self.db_tmp_path)
if os.path.exists(self.tmp_folder):
shutil.rmtree(self.tmp_folder)
break
except Exception as e:
except:
time.sleep(1)
retries += 1
print(e)
def delete_column_test(self):
"""

View File

@ -65,8 +65,6 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
"""
Set up anything necessary for all tests
"""
if os.path.exists(TEST_DB):
os.unlink(TEST_DB)
mocked_init_url.return_value = 'sqlite:///{}'.format(TEST_DB)
self.build_settings()
self.setup_application()
@ -90,6 +88,14 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
self.projectordb.session.close()
del(self.projectordb)
del(self.projector)
while retries < 5:
try:
if os.path.exists(TEST_DB):
os.unlink(TEST_DB)
break
except:
time.sleep(1)
retries += 1
self.destroy_settings()
def source_dict_test(self):