From 48eeb50d0291f689abd44b1820d5a406f926543b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Jan 2016 21:14:24 +0200 Subject: [PATCH] Add retries around other db removals --- tests/functional/openlp_core_lib/test_projectordb.py | 10 ++++++++-- tests/functional/openlp_core_utils/test_db.py | 7 +++---- .../openlp_core_ui/test_projectorsourceform.py | 10 ++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index 58eff13bc..8243292d0 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -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): """ diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core_utils/test_db.py index 7ac3c1440..f2c3d264a 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core_utils/test_db.py @@ -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): """ diff --git a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py index b4951e910..3b08db149 100644 --- a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py +++ b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py @@ -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):