本文整理汇总了Python中Orange.widgets.settings.SettingsHandler.provider方法的典型用法代码示例。如果您正苦于以下问题:Python SettingsHandler.provider方法的具体用法?Python SettingsHandler.provider怎么用?Python SettingsHandler.provider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.widgets.settings.SettingsHandler
的用法示例。
在下文中一共展示了SettingsHandler.provider方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_initialize_with_no_provider
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import provider [as 别名]
def test_initialize_with_no_provider(self, SettingProvider):
""":type SettingProvider: unittest.mock.Mock"""
handler = SettingsHandler()
handler.provider = Mock(get_provider=Mock(return_value=None))
provider = Mock()
SettingProvider.return_value = provider
widget = SimpleWidget()
# initializing an undeclared provider should display a warning
with warnings.catch_warnings(record=True) as w:
handler.initialize(widget)
self.assertEqual(1, len(w))
SettingProvider.assert_called_once_with(SimpleWidget)
provider.initialize.assert_called_once_with(widget, None)
示例2: test_initialize_component
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import provider [as 别名]
def test_initialize_component(self):
handler = SettingsHandler()
handler.defaults = {'default': 42}
provider = Mock()
handler.provider = Mock(get_provider=Mock(return_value=provider))
widget = SimpleWidget()
# No data
handler.initialize(widget)
provider.initialize.assert_called_once_with(widget, None)
# Dictionary data
provider.reset_mock()
handler.initialize(widget, {'setting': 5})
provider.initialize.assert_called_once_with(widget, {'setting': 5})
# Pickled data
provider.reset_mock()
handler.initialize(widget, pickle.dumps({'setting': 5}))
provider.initialize.assert_called_once_with(widget, {'setting': 5})