diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index dd61bf33b..3559e9e8c 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -96,6 +96,7 @@ class TestProjectorDB(TestCase): """ Clean up """ + self.projector.session.close() self.projector = None 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 b41d23ac7..695a25586 100644 --- a/tests/interfaces/openlp_core_ui/test_projectormanager.py +++ b/tests/interfaces/openlp_core_ui/test_projectormanager.py @@ -22,7 +22,6 @@ """ Interface tests to test the themeManager class and related methods. """ - import os from unittest import TestCase @@ -33,9 +32,7 @@ from tests.helpers.testmixin import TestMixin from openlp.core.ui import ProjectorManager, ProjectorEditForm from openlp.core.lib.projector.db import Projector, ProjectorDB -from tests.resources.projector.data import TEST1_DATA, TEST2_DATA, TEST3_DATA - -tmpfile = '/tmp/openlp-test-projectormanager.sql' +from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA class TestProjectorManager(TestCase, TestMixin): @@ -49,12 +46,13 @@ class TestProjectorManager(TestCase, TestMixin): self.build_settings() self.setup_application() Registry.create() - if not hasattr(self, 'projector_manager'): - with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url: - mocked_init_url.return_value = 'sqlite:///%s' % tmpfile - self.projectordb = ProjectorDB() - if not hasattr(self, 'projector_manager'): - self.projector_manager = ProjectorManager(projectordb=self.projectordb) + 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.projectordb = ProjectorDB() + if not hasattr(self, 'projector_manager'): + self.projector_manager = ProjectorManager(projectordb=self.projectordb) def tearDown(self): """