def test_mpushbutton_init(qtbot, dayu_type, dayu_size, icon, text): """Test MPushButton set_dayu_size and set_dayu_type.""" widget = MPushButton(icon=MIcon(icon) if icon else icon, text=text) widget.set_dayu_size(dayu_size) widget.set_dayu_type(dayu_type) qtbot.addWidget(widget) assert widget.property('dayu_type') == dayu_type assert widget.property('dayu_size') == dayu_size
def test_with_wrong_type(qtbot, input_type): """Test MPushButton set_dayu_type method with wrong arg. raise ValueError.""" with pytest.raises(ValueError) as exc_info: widget = MPushButton() widget.set_dayu_type(input_type) qtbot.addWidget(widget) exception_msg = exc_info.value.args[0] assert exception_msg == "Input argument 'value' should be one of " \ "default/primary/success/warning/danger string."
def create_button(self, data_dict): button = MPushButton() button.set_dayu_size(data_dict.get('dayu_size', self._dayu_size)) button.set_dayu_type(data_dict.get('dayu_type', self._dayu_type)) return button