本文整理汇总了Python中safe.impact_functions.registry.Registry.clear方法的典型用法代码示例。如果您正苦于以下问题:Python Registry.clear方法的具体用法?Python Registry.clear怎么用?Python Registry.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe.impact_functions.registry.Registry
的用法示例。
在下文中一共展示了Registry.clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_register_and_clear
# 需要导入模块: from safe.impact_functions.registry import Registry [as 别名]
# 或者: from safe.impact_functions.registry.Registry import clear [as 别名]
def test_register_and_clear(self):
"""TestRegistry: Test register and clear impact function."""
registry = Registry()
registry.clear()
message = 'Expecting registry should be cleared. %s impact ' \
'functions exists instead' % len(registry.impact_functions)
self.assertEqual(0, len(registry.impact_functions), message)
registry.register(FloodPolygonBuildingFunction)
message = 'Expecting registry will contains 1 impact functions. %s ' \
'impact functions exists' % len(registry.impact_functions)
self.assertEqual(1, len(registry.impact_functions), message)
result = registry.get_instance('FloodPolygonBuildingFunction')\
.metadata().as_dict()['id']
expected = 'FloodPolygonBuildingFunction'
message = 'Expected registered impact function ID should be %s. ' \
'Got %s instead' % (expected, result)
self.assertEqual(expected, result, message)