1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Fix random behavior in tests

This commit is contained in:
Julien Duponchelle 2015-03-17 15:40:58 +01:00
parent bb7eda63af
commit 964ea0f577
2 changed files with 16 additions and 7 deletions

View File

@ -45,9 +45,6 @@ class Config(object):
# Monitor configuration files for changes
self._watched_files = {}
# Override config from command line even if we modify the config file and live reload it.
self._override_config = {}
if sys.platform.startswith("win"):
appname = "GNS3"
@ -90,10 +87,17 @@ class Config(object):
os.path.join("/etc/xdg", appname + ".conf"),
filename]
self._config = configparser.ConfigParser()
self.read_config()
self.clear()
self._watch_config_file()
def clear(self):
"""Restart with a clean config"""
self._config = configparser.ConfigParser()
# Override config from command line even if we modify the config file and live reload it.
self._override_config = {}
self.read_config()
def _watch_config_file(self):
asyncio.get_event_loop().call_later(1, self._check_config_file_change)
@ -185,7 +189,12 @@ class Config(object):
If the section doesn't exists the section is created
"""
self.set_section_config(section, {key: value})
conf = self.get_section_config(section)
if isinstance(value, bool):
conf[key] = str(value)
else:
conf[key] = value
self.set_section_config(section, conf)
@staticmethod
def instance(files=None):

View File

@ -133,8 +133,8 @@ def run_around_tests(monkeypatch):
tmppath = tempfile.mkdtemp()
Config.reset()
config = Config.instance()
config.clear()
config.set("Server", "project_directory", tmppath)
# Prevent exectuions of the VM if we forgot to mock something