def test_SheetController_begin_sheet(): from editxt.controls.alert import Caller m = Mocker() tv = m.mock(TextView) slc = SheetController(tv) def cb(callback): return callback.__name__ == "sheet_did_end" and callback.__self__ is slc clr_class = m.replace(mod, "Caller") clr = clr_class.alloc().init(MATCH(cb)) >> m.mock(Caller) win = tv.window() >> m.mock(ak.NSWindow) pnl = m.method(slc.gui.window)() >> m.mock(ak.NSPanel) nsapp = m.replace(ak, 'NSApp', spec=False) nsapp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_( pnl, win, clr, "alertDidEnd:returnCode:contextInfo:", 0) with m: slc.begin_sheet(None)
def test_SheetController_begin_sheet(): class FakeEditor(object): pass with test_app() as app: m = Mocker() editor = FakeEditor() editor.app = app editor.text_view = TestConfig(window=lambda:win) win = m.mock(ak.NSWindow) slc = SheetController(editor) def cb(callback): return (callback.__name__ == "sheet_did_end" and callback.__self__ is slc) clr_class = m.replace(mod, "Caller") clr = clr_class(MATCH(cb)) >> m.mock(Caller) pnl = m.method(slc.gui.window)() >> m.mock(ak.NSPanel) nsapp = m.replace(ak, 'NSApp', spec=False) nsapp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_( pnl, win, clr, "alertDidEnd:returnCode:contextInfo:", 0) with m: slc.begin_sheet(None)