示例#1
0
文件: app.py 项目: socek/bluebaker
    def test_run(self):
        def mockup(self):
            self._mainloop = True

        app = Application()
        with nested(
                patch.object(app, 'createTopWindow'),
                patch.object(Application, 'mainloop', mockup),
                patch('bluebaker.app.info'),
        ) as (createTopWindow, mainloop, info):
            app.run()
            info.assert_called_once_with(' === Program ended ===')
        self.assertTrue(app._mainloop)
示例#2
0
文件: app.py 项目: socek/bluebaker
    def test_run_KeyboardInterrupt(self):
        def side_effect():
            raise KeyboardInterrupt()

        def mockup(self):
            self._mainloop = True

        app = Application()
        app._mainloop = False
        with nested(
                patch.object(app, 'createTopWindow', side_effect=side_effect),
                patch.object(Application, 'mainloop', mockup),
                patch('bluebaker.app.info'),
        ) as (createTopWindow, mainloop, info):
            app.run()
            info.assert_called_with(' === Program ended ===')
        self.assertFalse(app._mainloop)