本文整理汇总了Python中lsst.pex.policy.Policy.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Policy.remove方法的具体用法?Python Policy.remove怎么用?Python Policy.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lsst.pex.policy.Policy
的用法示例。
在下文中一共展示了Policy.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSelfValidation
# 需要导入模块: from lsst.pex.policy import Policy [as 别名]
# 或者: from lsst.pex.policy.Policy import remove [as 别名]
def testSelfValidation(self):
# assign a dictionary after creation
p = Policy(self.getTestDictionary("types_policy_good.paf"))
p.loadPolicyFiles(self.getTestDictionary(), True)
typesDict = Dictionary(self.getTestDictionary("types_dictionary.paf"))
valuesDict = Dictionary(self.getTestDictionary("values_dictionary.paf"))
self.assert_(not p.canValidate())
p.setDictionary(typesDict)
self.assert_(p.canValidate())
p.validate()
p.set("bool_type", True)
self.assertValidationError(
ValidationError.WRONG_TYPE, p.set, "bool_type", "foo")
# create with dictionary
p = Policy.createPolicy(self.getTestDictionary("types_dictionary.paf"), "", True)
self.assert_(p.canValidate())
p.set("bool_type", True)
self.assertValidationError(
ValidationError.WRONG_TYPE, p.set, "bool_type", "foo")
# assign a dictionary after invalid modifications
p = Policy()
p.set("bool_type", "foo")
p.setDictionary(typesDict)
ve = ValidationError("Dictionary_1.py", 1, "testSelfValidation")
p.validate(ve.cpp)
self.assert_(ve.getErrors("bool_type") == ValidationError.WRONG_TYPE)
try:
p.validate()
except ValidationError as ve:
self.assert_(ve.getErrors("bool_type") == ValidationError.WRONG_TYPE)
self.assert_(ve.getParamCount() == 1)
p.set("bool_type", True)
p.set("int_type", 1)
p.validate()
# switch dictionaries
oldD = p.getDictionary()
p.setDictionary(valuesDict)
try:
p.validate()
except ValidationError as ve:
self.assert_(ve.getErrors("bool_type")
== ValidationError.UNKNOWN_NAME)
p.set("string_range_type", "moo")
try:
p.set("string_range_type", "victor")
except ValidationError as ve:
self.assert_(ve.getErrors("string_range_type")
== ValidationError.VALUE_OUT_OF_RANGE)
p.setDictionary(oldD)
p.remove("string_range_type")
p.validate()