本文整理汇总了Python中kamaki.cli.config.Config.guess_version方法的典型用法代码示例。如果您正苦于以下问题:Python Config.guess_version方法的具体用法?Python Config.guess_version怎么用?Python Config.guess_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kamaki.cli.config.Config
的用法示例。
在下文中一共展示了Config.guess_version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_guess_version
# 需要导入模块: from kamaki.cli.config import Config [as 别名]
# 或者: from kamaki.cli.config.Config import guess_version [as 别名]
def test_guess_version(self):
from kamaki.cli.config import Config
from kamaki.cli.logger import add_file_logger
def make_log_file():
f = NamedTemporaryFile()
add_file_logger('kamaki.cli.config', filename=f.name)
return f
def make_file(lines):
f = NamedTemporaryFile()
f.writelines(lines)
f.flush()
return f
with make_file([]) as f:
with make_log_file() as logf:
_cnf = Config(path=f.name)
self.assertEqual(0.9, _cnf.guess_version())
exp = 'All heuristics failed, cannot decide\n'
logf.file.seek(- len(exp), 2)
self.assertEqual(exp, logf.read())
content0 = list(self.config_file_content)
with make_file(content0) as f:
with make_log_file() as logf:
_cnf = Config(path=f.name)
self.assertEqual(0.9, _cnf.guess_version())
exp = '... found cloud "demo"\n'
logf.seek(- len(exp), 2)
self.assertEqual(exp, logf.read())
for term in ('url', 'token'):
content1 = list(content0)
content1.insert(2, '%s = some_value' % term)
with make_file(content1) as f:
with make_log_file() as logf:
_cnf = Config(path=f.name)
self.assertEqual(0.8, _cnf.guess_version())
exp = '..... config file has an old global section\n'
logf.seek(- len(exp), 2)
self.assertEqual(exp, logf.read())