本文整理汇总了Python中zirkon.config.Config.macros方法的典型用法代码示例。如果您正苦于以下问题:Python Config.macros方法的具体用法?Python Config.macros怎么用?Python Config.macros使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zirkon.config.Config
的用法示例。
在下文中一共展示了Config.macros方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Config_err_disabled_macros
# 需要导入模块: from zirkon.config import Config [as 别名]
# 或者: from zirkon.config.Config import macros [as 别名]
def test_Config_err_disabled_macros():
config = Config(macros=False)
config['x'] = 10
config['sub'] = {'sub': {}}
with pytest.raises(ValueError) as exc_info:
config['y'] = ROOT['x'] + 1
assert str(exc_info.value) == "cannot set y=ROOT['x'] + 1: macros are not enabled"
with pytest.raises(ValueError) as exc_info:
config['sub']['sub']['y'] = ROOT['x'] + 1
assert str(exc_info.value) == "cannot set y=ROOT['x'] + 1: macros are not enabled"
config.macros = True
config['sub']['sub']['y'] = ROOT['x'] + 1
assert config['sub']['sub']['y'] == 11
config.macros = False
with pytest.raises(ValueError) as exc_info:
c = config['sub']['sub']['y']
assert str(exc_info.value) == "cannot evaluate ROOT['x'] + 1: macros are not enabled"