mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Fix tests due to test reading the local config file
This commit is contained in:
parent
b419001813
commit
a4669689e7
@ -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
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user