Fixes settings initialization in tests to actually use temporary ini file.

This commit is contained in:
Jonathan Springer 2014-03-12 01:31:19 -04:00
parent 03d6d374a4
commit 6f05711414
8 changed files with 12 additions and 8 deletions

View File

@ -46,6 +46,7 @@ class TestSettings(TestCase):
"""
Create the UI
"""
Settings.setDefaultFormat(Settings.IniFormat)
fd, self.ini_file = mkstemp('.ini')
Settings().set_filename(self.ini_file)
self.application = QtGui.QApplication.instance()
@ -55,7 +56,6 @@ class TestSettings(TestCase):
Delete all the C++ objects at the end so that we don't have a segfault
"""
del self.application
os.unlink(self.ini_file)
os.unlink(Settings().fileName())
def settings_basic_test(self):

View File

@ -59,7 +59,7 @@ class TestActionList(TestCase):
Clean up
"""
self.settings.endGroup()
os.unlink(self.ini_file)
os.unlink(Settings().fileName())
def test_add_action_same_parent(self):
"""

View File

@ -55,6 +55,7 @@ class TestPdfController(TestCase):
"""
Set up the components need for all tests.
"""
Settings.setDefaultFormat(Settings.IniFormat)
self.fd, self.ini_file = mkstemp('.ini')
Settings().set_filename(self.ini_file)
self.application = QtGui.QApplication.instance()
@ -69,7 +70,7 @@ class TestPdfController(TestCase):
"""
del self.application
try:
os.unlink(self.ini_file)
os.unlink(Settings().fileName())
shutil.rmtree(self.thumbnail_folder)
shutil.rmtree(self.temp_folder)
except OSError:

View File

@ -62,6 +62,7 @@ class TestRemoteTab(TestCase):
"""
Create the UI
"""
Settings.setDefaultFormat(Settings.IniFormat)
self.fd, self.ini_file = mkstemp('.ini')
Settings().set_filename(self.ini_file)
self.application = QtGui.QApplication.instance()
@ -77,7 +78,7 @@ class TestRemoteTab(TestCase):
del self.parent
del self.form
os.close(self.fd)
os.unlink(self.ini_file)
os.unlink(Settings().fileName())
def get_ip_address_default_test(self):
"""

View File

@ -61,6 +61,7 @@ class TestRouter(TestCase):
"""
Create the UI
"""
Settings.setDefaultFormat(Settings.IniFormat)
self.fd, self.ini_file = mkstemp('.ini')
Settings().set_filename(self.ini_file)
self.application = QtGui.QApplication.instance()
@ -73,7 +74,7 @@ class TestRouter(TestCase):
"""
del self.application
os.close(self.fd)
os.unlink(self.ini_file)
os.unlink(Settings().fileName())
def password_encrypter_test(self):
"""

View File

@ -28,6 +28,7 @@ class TestMediaItem(TestCase):
patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__'):
self.media_item = SongMediaItem(None, MagicMock())
Settings.setDefaultFormat(Settings.IniFormat)
fd, self.ini_file = mkstemp('.ini')
Settings().set_filename(self.ini_file)
self.application = QtGui.QApplication.instance()
@ -40,7 +41,6 @@ class TestMediaItem(TestCase):
del self.application
# Not all tests use settings!
try:
os.unlink(self.ini_file)
os.unlink(Settings().fileName())
except Exception:
pass

View File

@ -23,6 +23,7 @@ class TestPluginManager(TestCase):
"""
Some pre-test setup required.
"""
Settings.setDefaultFormat(Settings.IniFormat)
fd, self.ini_file = mkstemp('.ini')
self.temp_dir = mkdtemp('openlp')
Settings().set_filename(self.ini_file)
@ -38,7 +39,7 @@ class TestPluginManager(TestCase):
del self.main_window
Settings().remove('advanced/data path')
shutil.rmtree(self.temp_dir)
os.unlink(self.ini_file)
os.unlink(Settings().fileName())
def find_plugins_test(self):
"""

View File

@ -48,6 +48,7 @@ class TestThemeManager(TestCase):
"""
Create the UI
"""
Settings.setDefaultFormat(Settings.IniFormat)
fd, self.ini_file = mkstemp('.ini')
Settings().set_filename(self.ini_file)
self.app = QtGui.QApplication([])
@ -58,7 +59,6 @@ class TestThemeManager(TestCase):
"""
Delete all the C++ objects at the end so that we don't have a segfault
"""
os.unlink(self.ini_file)
os.unlink(Settings().fileName())
del self.app