本文整理汇总了Python中gns3server.config.Config.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Config.reset方法的具体用法?Python Config.reset怎么用?Python Config.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gns3server.config.Config
的用法示例。
在下文中一共展示了Config.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_arguments
# 需要导入模块: from gns3server.config import Config [as 别名]
# 或者: from gns3server.config.Config import reset [as 别名]
def test_parse_arguments(capsys, tmpdir):
Config.reset()
config = Config.instance(str(tmpdir / "test.cfg"))
server_config = config.get_section_config("Server")
with pytest.raises(SystemExit):
main.parse_arguments(["--fail"], server_config)
out, err = capsys.readouterr()
assert "usage" in err
assert "fail" in err
assert "unrecognized arguments" in err
with pytest.raises(SystemExit):
main.parse_arguments(["-v"], server_config)
out, err = capsys.readouterr()
assert __version__ in "{}{}".format(out, err) # Depending of the Python version the location of the version change
with pytest.raises(SystemExit):
main.parse_arguments(["--version"], server_config)
out, err = capsys.readouterr()
assert __version__ in "{}{}".format(out, err) # Depending of the Python version the location of the version change
with pytest.raises(SystemExit):
main.parse_arguments(["-h"], server_config)
out, err = capsys.readouterr()
assert __version__ in out
assert "optional arguments" in out
with pytest.raises(SystemExit):
main.parse_arguments(["--help"], server_config)
out, err = capsys.readouterr()
assert __version__ in out
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 == "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"
assert main.parse_arguments(["--port", "8002"], server_config).port == 8002
assert main.parse_arguments([], server_config).port == 8000
server_config["port"] = "8003"
assert main.parse_arguments([], server_config).port == 8003
assert main.parse_arguments(["--ssl"], server_config).ssl
assert main.parse_arguments([], server_config).ssl is False
server_config["ssl"] = "True"
assert main.parse_arguments([], server_config).ssl
assert main.parse_arguments(["--certfile", "bla"], server_config).certfile == "bla"
assert main.parse_arguments([], server_config).certfile == ""
assert main.parse_arguments(["--certkey", "blu"], server_config).certkey == "blu"
assert main.parse_arguments([], server_config).certkey == ""
assert main.parse_arguments(["-L"], server_config).local
assert main.parse_arguments(["--local"], server_config).local
assert main.parse_arguments([], server_config).local is False
server_config["local"] = "True"
assert main.parse_arguments([], server_config).local
assert main.parse_arguments(["-A"], server_config).allow
assert main.parse_arguments(["--allow"], server_config).allow
assert main.parse_arguments([], server_config).allow is False
server_config["allow_remote_console"] = "True"
assert main.parse_arguments([], server_config).allow
assert main.parse_arguments(["-q"], server_config).quiet
assert main.parse_arguments(["--quiet"], server_config).quiet
assert main.parse_arguments([], server_config).quiet is False
assert main.parse_arguments(["-d"], server_config).debug
assert main.parse_arguments([], server_config).debug is False
server_config["debug"] = "True"
assert main.parse_arguments([], server_config).debug