From 6af0aef8bd659d1ad64a58ef48a340ce45148eee Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Fri, 28 Nov 2014 10:53:39 +0000 Subject: [PATCH] Another attempt to fix projector test across platforms and versions --- tests/functional/openlp_core_lib/test_projectordb.py | 7 +++++-- tests/interfaces/openlp_core_ui/test_projectormanager.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index d92258ff9..4dd5f52a3 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -85,8 +85,11 @@ class TestProjectorDB(TestCase): Set up anything necessary for all tests """ if not hasattr(self, 'projector'): - with patch('openlp.core.lib.db.init_url') as mocked_init_url: - mocked_init_url.return_value = 'sqlite:///%s' % tmpfile + # We need to patch this twice to make it work across multiple platforms and versions. + with patch('openlp.core.lib.db.init_url') as mocked_init_url1, \ + patch('openlp.core.lib.projector.db.init_url') as mocked_init_url2: + mocked_init_url1.return_value = 'sqlite:///%s' % tmpfile + mocked_init_url2.return_value = 'sqlite:///%s' % tmpfile self.projector = ProjectorDB() def find_record_by_ip_test(self): diff --git a/tests/interfaces/openlp_core_ui/test_projectormanager.py b/tests/interfaces/openlp_core_ui/test_projectormanager.py index 9ecbaca38..edfaa9a62 100644 --- a/tests/interfaces/openlp_core_ui/test_projectormanager.py +++ b/tests/interfaces/openlp_core_ui/test_projectormanager.py @@ -57,8 +57,11 @@ class TestProjectorManager(TestCase, TestMixin): self.setup_application() Registry.create() if not hasattr(self, 'projector_manager'): - with patch('openlp.core.lib.db.init_url') as mocked_init_url: - mocked_init_url.return_value = 'sqlite:///%s' % tmpfile + # We need to patch this twice to make it work across multiple platforms and versions. + with patch('openlp.core.lib.db.init_url') as mocked_init_url1, \ + patch('openlp.core.lib.projector.db.init_url') as mocked_init_url2: + mocked_init_url1.return_value = 'sqlite:///%s' % tmpfile + mocked_init_url2.return_value = 'sqlite:///%s' % tmpfile self.projectordb = ProjectorDB() if not hasattr(self, 'projector_manager'): self.projector_manager = ProjectorManager(projectordb=self.projectordb)