本文整理汇总了Python中safe_extras.parameters.boolean_parameter.BooleanParameter.is_required方法的典型用法代码示例。如果您正苦于以下问题:Python BooleanParameter.is_required方法的具体用法?Python BooleanParameter.is_required怎么用?Python BooleanParameter.is_required使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe_extras.parameters.boolean_parameter.BooleanParameter
的用法示例。
在下文中一共展示了BooleanParameter.is_required方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init
# 需要导入模块: from safe_extras.parameters.boolean_parameter import BooleanParameter [as 别名]
# 或者: from safe_extras.parameters.boolean_parameter.BooleanParameter import is_required [as 别名]
def test_init(self):
parameter = BooleanParameter('1231231')
parameter.name = 'Boolean'
parameter.help_text = 'A boolean parameter'
parameter.description = 'A test _description'
parameter.is_required = True
parameter.value = True
widget = BooleanParameterWidget(parameter)
expected_value = parameter.name
real_value = widget._label.text()
message = 'Expected %s get %s' % (expected_value, real_value)
self.assertEqual(expected_value, real_value, message)
expected_value = parameter.value
real_value = widget._check_box_input.isChecked()
message = 'Expected %s get %s' % (expected_value, real_value)
self.assertEqual(expected_value, real_value, message)
# change value
widget._check_box_input.setChecked(False)
expected_value = False
real_value = widget._check_box_input.isChecked()
message = 'Expected %s get %s' % (expected_value, real_value)
self.assertEqual(expected_value, real_value, message)
示例2: test_init
# 需要导入模块: from safe_extras.parameters.boolean_parameter import BooleanParameter [as 别名]
# 或者: from safe_extras.parameters.boolean_parameter.BooleanParameter import is_required [as 别名]
def test_init(self):
"""Test initialize qt4 parameter factory."""
boolean_parameter = BooleanParameter('1231231')
boolean_parameter.name = 'Boolean'
boolean_parameter.help_text = 'A boolean parameter'
boolean_parameter.description = 'A test _description'
boolean_parameter.is_required = True
boolean_parameter.value = True
float_parameter = FloatParameter()
float_parameter.name = 'Float Parameter'
float_parameter.is_required = True
float_parameter.precision = 3
float_parameter.minimum_allowed_value = 1.0
float_parameter.maximum_allowed_value = 2.0
float_parameter.help_text = 'Short help.'
float_parameter.description = 'Long description for parameter.'
float_parameter.unit = 'metres'
float_parameter.value = 1.1
parameters = [boolean_parameter, float_parameter]
qt4_parameter_factory = Qt4ParameterFactory()
widgets = []
widget_classes = []
for parameter in parameters:
widget = qt4_parameter_factory.get_widget(parameter)
widgets.append(widget)
widget_classes.append(widget.__class__)
expected_classes = [BooleanParameterWidget, FloatParameterWidget]
message = 'Expected %s got %s' % (expected_classes, widget_classes)
self.assertListEqual(widget_classes, expected_classes, message)
示例3: test_boolean
# 需要导入模块: from safe_extras.parameters.boolean_parameter import BooleanParameter [as 别名]
# 或者: from safe_extras.parameters.boolean_parameter.BooleanParameter import is_required [as 别名]
def test_boolean(self):
"""Test a bool parameter works properly.
.. versionadded:: 2.2
"""
parameter = BooleanParameter('1231231')
parameter.name = 'Boolean'
parameter.help_text = 'A boolean parameter'
parameter.description = 'A test _description'
parameter.is_required = True
parameter.value = True
self.assertEqual(True, parameter.value)
with self.assertRaises(TypeError):
parameter.value = 'Test'
示例4: building_type_field
# 需要导入模块: from safe_extras.parameters.boolean_parameter import BooleanParameter [as 别名]
# 或者: from safe_extras.parameters.boolean_parameter.BooleanParameter import is_required [as 别名]
def building_type_field():
field = BooleanParameter()
field.name = 'Building Type Field'
field.is_required = True
field.value = True
return field