本文整理汇总了Python中Shine.Configuration.ModelFile.ModelFile.content方法的典型用法代码示例。如果您正苦于以下问题:Python ModelFile.content方法的具体用法?Python ModelFile.content怎么用?Python ModelFile.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shine.Configuration.ModelFile.ModelFile
的用法示例。
在下文中一共展示了ModelFile.content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testModelBaseMethods
# 需要导入模块: from Shine.Configuration.ModelFile import ModelFile [as 别名]
# 或者: from Shine.Configuration.ModelFile.ModelFile import content [as 别名]
def testModelBaseMethods(self):
"""test ModelFile base methods"""
model = ModelFile()
# content() with a default value
self.assertEqual(model.content('default'), 'default')
model.add_element('foo', check='string', multiple=True)
# get() with a default value
self.assertEqual(model.get('foo', 'default'), 'default')
# Only key with non-empty value are taken in account
self.assertEqual(len(model), 0)
# parse()
self.assertRaises(ModelFileValueError, model.parse, "foo one two")
# __contains__() False
self.assertFalse('foo' in model)
# iter()
model.add('foo', "5 6")
model.add('foo', "6 7")
self.assertEqual(list(iter(model)), ['foo'])
# __contains__() True
self.assertTrue('foo' in model)
示例2: testModelBaseMethods
# 需要导入模块: from Shine.Configuration.ModelFile import ModelFile [as 别名]
# 或者: from Shine.Configuration.ModelFile.ModelFile import content [as 别名]
def testModelBaseMethods(self):
"""test ModelFile base methods"""
model = ModelFile()
# content() with a default value
self.assertEqual(model.content('default'), 'default')
model.add_element('foo', check='string', multiple=True)
# get() with a default value
self.assertEqual(model.get('foo', 'default'), 'default')
# Only key with non-empty value are taken in account
self.assertEqual(len(model), 0)
# parse() bad syntax
self.assertRaises(ModelFileValueError, model.parse, "foo one two")
# parse() with good syntax, but unknown key
self.assertRaises(ModelFileValueError, model.parse, "good: syntax")
# __contains__() False
self.assertFalse('foo' in model)
# iter()
model.add('foo', "5 6")
model.add('foo', "6 7")
self.assertEqual(list(iter(model)), ['foo'])
# __contains__() True
self.assertTrue('foo' in model)
# replace()
model.replace('foo', "other")
self.assertEqual(model.get('foo'), ['other'])
# __eq__()
other = model.emptycopy()
self.assertNotEqual(model, other)
other.add("foo", "other")
self.assertEqual(model, other)
self.assertNotEqual(model, "bad type object")