当前位置: 首页>>代码示例>>Python>>正文


Python BaseWizard.need_cancel_confirmation方法代码示例

本文整理汇总了Python中stoqlib.gui.base.wizards.BaseWizard.need_cancel_confirmation方法的典型用法代码示例。如果您正苦于以下问题:Python BaseWizard.need_cancel_confirmation方法的具体用法?Python BaseWizard.need_cancel_confirmation怎么用?Python BaseWizard.need_cancel_confirmation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stoqlib.gui.base.wizards.BaseWizard的用法示例。


在下文中一共展示了BaseWizard.need_cancel_confirmation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_cancel_confirmation_close

# 需要导入模块: from stoqlib.gui.base.wizards import BaseWizard [as 别名]
# 或者: from stoqlib.gui.base.wizards.BaseWizard import need_cancel_confirmation [as 别名]
    def test_cancel_confirmation_close(self, yesno):
        step = _FakeStep(self.store, None)
        wizard = BaseWizard(self.store, step, title="Fake")

        # need_cancel_confirmation is False, cancel should close the wizard
        with mock.patch.object(wizard, 'close') as close:
            wizard.cancel()
            self.assertEquals(yesno.call_count, 0)
            close.assert_called_once()

        wizard.need_cancel_confirmation = True

        # need_cancel_confirmation is True but there're no changes. Cancel
        # should still close the dialog
        with mock.patch.object(wizard, 'close') as close:
            wizard.cancel()
            self.assertEquals(yesno.call_count, 0)
            close.assert_called_once()

        # Just to make store.get_pending_changes return something greater
        # thant the time the wizard was created
        self.create_sellable()

        yesno.return_value = True
        # need_cancel_confirmation is True and there're changes. yesno
        # should ask if we can close the wizard or not and since we are
        # answering True, it should still close
        with mock.patch.object(wizard, 'close') as close:
            wizard.cancel()
            yesno.assert_called_once_with(
                ("If you cancel this dialog all changes will be "
                 "lost. Are you sure?"),
                gtk.RESPONSE_NO, "Cancel", "Don't cancel")
            close.assert_called_once()

        yesno.reset_mock()
        yesno.return_value = False
        # need_cancel_confirmation is True and there're changes. yesno
        # should ask if we can close the wizard or not and since we are
        # answering False, it should not close
        with mock.patch.object(wizard, 'close') as close:
            wizard.cancel()
            yesno.assert_called_once_with(
                ("If you cancel this dialog all changes will be "
                 "lost. Are you sure?"),
                gtk.RESPONSE_NO, "Cancel", "Don't cancel")
            self.assertEquals(close.call_count, 0)
开发者ID:barkinet,项目名称:stoq,代码行数:49,代码来源:test_base_wizards.py


注:本文中的stoqlib.gui.base.wizards.BaseWizard.need_cancel_confirmation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。