clean up temporary conf file

This commit is contained in:
jleute 2018-05-19 02:42:45 +02:00
parent e00238427b
commit cfe5eb5d56

View file

@ -5,7 +5,7 @@ from twisted.trial import unittest
from lbrynet import conf from lbrynet import conf
from lbrynet.core.Error import InvalidCurrencyError from lbrynet.core.Error import InvalidCurrencyError
from lbrynet.tests import mocks from lbrynet.tests import mocks
from lbrynet.tests.util import create_conf_file from lbrynet.tests.util import create_conf_file, remove_conf_file
class SettingsTest(unittest.TestCase): class SettingsTest(unittest.TestCase):
def setUp(self): def setUp(self):
@ -84,7 +84,7 @@ class SettingsTest(unittest.TestCase):
conf_entry = 'lbryum_servers: ["localhost:50001", "localhost:50002"]\n' conf_entry = 'lbryum_servers: ["localhost:50001", "localhost:50002"]\n'
conf_temp = create_conf_file(conf_entry) conf_temp = create_conf_file(conf_entry)
conf.conf_file = conf_temp conf.conf_file = conf_temp
adjustable_settings={'data_dir': (str, conf.default_data_dir), adjustable_settings = {'data_dir': (str, conf.default_data_dir),
'lbryum_servers': (list, [('localhost', 5001)], 'lbryum_servers': (list, [('localhost', 5001)],
conf.server_list, conf.server_list_reverse)} conf.server_list, conf.server_list_reverse)}
env = conf.Env(**adjustable_settings) env = conf.Env(**adjustable_settings)
@ -93,6 +93,12 @@ class SettingsTest(unittest.TestCase):
settings.load_conf_file_settings() settings.load_conf_file_settings()
first = settings.get('lbryum_servers', data_type=conf.TYPE_PERSISTED) first = settings.get('lbryum_servers', data_type=conf.TYPE_PERSISTED)
settings.save_conf_file_settings() settings.save_conf_file_settings()
settings.load_conf_file_settings() try:
settings.load_conf_file_settings()
except Exception, e:
remove_conf_file(conf_temp)
raise Exception(e)
second = settings.get('lbryum_servers', data_type=conf.TYPE_PERSISTED) second = settings.get('lbryum_servers', data_type=conf.TYPE_PERSISTED)
remove_conf_file(conf_temp)
self.assertEqual(first, second) self.assertEqual(first, second)