本文整理汇总了Python中properties.Properties.pop方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.pop方法的具体用法?Python Properties.pop怎么用?Python Properties.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类properties.Properties
的用法示例。
在下文中一共展示了Properties.pop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runTest
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import pop [as 别名]
def runTest(self):
"""Test blank"""
prefString= ""
prefs = Properties(prefString)
prefString = "default.name=Bilbo Baggins\nhomepage.feeds=42,24"
prefs = Properties(prefString)
assert cmp('Bilbo Baggins', prefs.get('default.name')) == 0, 'Error retrieving value from key'
assert cmp('', prefs.get('jeff')) == 0, "Missing keys should default to blank string"
prefs.set('Hulk', 'Hogan')
assert cmp('Hogan', prefs.get('Hulk')) == 0, 'Error retrieving set key/value'
stringValue = prefs.convertToPropertiesFile()
#this last test needs to be fixed, can fail if keys are not brought back in same order
assert cmp(prefString + "\nHulk=Hogan", stringValue) == 0, 'Error converting to properties'
prefString = "jeff=1"
prefs = Properties(prefString)
assert cmp('1', prefs.get('jeff')) == 0
assert cmp('1', prefs.pop('jeff')) == 0
try:
prefs.pop('badkey')
unittest.fail('A KeyError exception should have prevented this')
except KeyError:
pass
assert False == prefs.has_key('jeff')