Exemple #1
0
def test_ChangeIndentationController_save_options():
    m = Mocker()
    tv = m.mock(TextView)
    dv = tv.doc_view >> m.mock(TextDocumentView)
    with m.order():
        mode = dv.indent_mode >> "<indent mode>"
        size = dv.indent_size >> "<indent size>"
    with m:
        ctl = ChangeIndentationController.create_with_textview(tv)
        ctl.save_options()
Exemple #2
0
def test_ChangeIndentationController_save_options():
    m = Mocker()
    tv = m.mock(TextView)
    dv = tv.doc_view >> m.mock(TextDocumentView)
    with m.order():
        mode = dv.indent_mode >> "<indent mode>"
        size = dv.indent_size >> "<indent size>"
    with m:
        ctl = ChangeIndentationController(tv)
        ctl.save_options()
Exemple #3
0
 def test(args=()):
     with test_app() as ac:
         m = Mocker()
         ed_class = m.replace(window, 'Window')
         ed = ed_class(ac, args[0] if args else None) >> m.mock(window.Window)
         with m.order():
             ac.windows.append(ed)
             ed.show(ac)
         with m:
             result = ac.create_window(*args)
             eq_(result, ed)
Exemple #4
0
 def test(c):
     m = Mocker()
     opc = OpenPathController.alloc().init()
     paths = m.property(opc, "paths").value >> m.mock(ak.NSTextView)
     with m.order():
         ts = paths.textStorage() >> m.mock(ak.NSTextStorage)
         #ts.deleteCharactersInRange_((0, ts.string().length() >> c.len0))
         paths.setSelectedRange_((0, ts.string().length() >> c.len0))
         paths.pasteAsPlainText_(opc)
         paths.setSelectedRange_((0, ts.string().length() >> c.len1))
     with m:
         opc.populateWithClipboard()
Exemple #5
0
 def test(c):
     m = Mocker()
     opc = OpenPathController(None)
     paths = m.property(opc, "paths").value >> m.mock(ak.NSTextView)
     with m.order():
         ts = paths.textStorage() >> m.mock(ak.NSTextStorage)
         #ts.deleteCharactersInRange_((0, ts.string().length() >> c.len0))
         paths.setSelectedRange_((0, ts.string().length() >> c.len0))
         paths.pasteAsPlainText_(opc)
         paths.setSelectedRange_((0, ts.string().length() >> c.len1))
     with m:
         opc.populateWithClipboard()
Exemple #6
0
 def test(c):
     m = Mocker()
     regundo = m.replace(mod, 'register_undo_callback')
     repnl = m.replace(mod, 'replace_newlines')
     doc = m.mock(TextDocument)
     with m.off_the_record():
         dv = Editor(None, document=doc)
     proxy = m.property(dv, 'proxy')
     with m.order():
         (getattr(doc, c.attr) << c.default).count(2 if c.value != c.default else 3)
         if c.value != c.default:
             c.do(TestConfig(**locals()))
             getattr(doc, c.attr) >> c.value
     with m:
         property_value_util(c, dv)
Exemple #7
0
 def test(args):
     ac = Application()
     m = Mocker()
     ed_class = m.replace(editor, 'Editor')
     wc_class = m.replace(editor, 'EditorWindowController')
     wc = wc_class.alloc() >> m.mock(editor.EditorWindowController)
     wc.initWithWindowNibName_("EditorWindow") >> wc
     ed = ed_class(ac, wc, args[0] if args else None) >> m.mock(editor.Editor)
     wc.editor = ed
     #ed = wc.controller >> m.mock(Editor)
     #wc_class.create_with_serial_data(args[0] if args else None) >> wc
     with m.order():
         ac.editors.append(ed)
         wc.showWindow_(ac)
     with m:
         result = ac.create_editor(*args)
         eq_(result, ed)
Exemple #8
0
 def test(args):
     ac = Application()
     m = Mocker()
     ed_class = m.replace(editor, 'Editor')
     wc_class = m.replace(editor, 'EditorWindowController')
     wc = wc_class.alloc() >> m.mock(editor.EditorWindowController)
     wc.initWithWindowNibName_("EditorWindow") >> wc
     ed = ed_class(ac, wc, args[0] if args else None) >> m.mock(
         editor.Editor)
     wc.editor = ed
     #ed = wc.controller >> m.mock(Editor)
     #wc_class.create_with_serial_data(args[0] if args else None) >> wc
     with m.order():
         ac.editors.append(ed)
         wc.showWindow_(ac)
     with m:
         result = ac.create_editor(*args)
         eq_(result, ed)
def test_wait_for_presence_works_even_when_is_visible_raises():
    
    mocker = Mocker()
    
    context = Context(Settings())
    selenium_mock = mocker.mock()
    selenium_mock.is_element_present('some element')
    mocker.count(min=1, max=None)
    mocker.result(True)
    
    with mocker.order():
        selenium_mock.is_visible('some element')
        mocker.throw(Exception("ERROR: Element some element not found"))
        selenium_mock.is_visible('some element')
        mocker.result(True)

    with mocker:
        driver = SeleniumDriver(context, selenium=selenium_mock)
        driver.wait_for_element_present("some element", 1)