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

Fix tests due to test reading the local config file

This commit is contained in:
Julien Duponchelle 2015-02-13 11:15:11 +01:00
parent b419001813
commit a4669689e7
2 changed files with 14 additions and 5 deletions

View File

@ -190,6 +190,14 @@ class Config(object):
:returns: instance of Config
"""
if not hasattr(Config, "_instance"):
Config._instance = Config()
if not hasattr(Config, "_instance") or Config._instance is None:
Config._instance = Config(files)
return Config._instance
@staticmethod
def reset():
"""
Reset singleton
"""
Config._instance = None

View File

@ -35,9 +35,10 @@ def test_locale_check():
assert locale.getlocale() == ('fr_FR', 'UTF-8')
def test_parse_arguments(capsys):
def test_parse_arguments(capsys, tmpdir):
config = Config.instance()
Config.reset()
config = Config.instance(str(tmpdir / "test.cfg"))
server_config = config.get_section_config("Server")
with pytest.raises(SystemExit):
@ -70,7 +71,7 @@ def test_parse_arguments(capsys):
assert "optional arguments" in out
assert main.parse_arguments(["--host", "192.168.1.1"], server_config).host == "192.168.1.1"
assert main.parse_arguments([], server_config).host == "127.0.0.1"
assert main.parse_arguments([], server_config).host == "0.0.0.0"
server_config["host"] = "192.168.1.2"
assert main.parse_arguments(["--host", "192.168.1.1"], server_config).host == "192.168.1.1"
assert main.parse_arguments([], server_config).host == "192.168.1.2"