Beispiel #1
0
def test_WrapLinesController_default_options():
    with replace_history() as history:
        ctl = WrapLinesController(None)
        eq_(ctl.options._target, mod.Options(
            wrap_column=const.DEFAULT_RIGHT_MARGIN,
            indent=True,
        ))
Beispiel #2
0
 def test(command, options):
     m = Mocker()
     nspb = m.replace(ak, 'NSPasteboard')
     pboard = nspb.pasteboardWithName_(ak.NSFindPboard)
     pboard.availableTypeFromArray_([ak.NSStringPboardType]) >> None
     with m, replace_history() as history:
         fc = FindController()
         sender = Config(selectedItem=lambda:Config(title=lambda:command))
         fc.recentFindSelected_(sender)
         eq_(fc.options._target, options)
Beispiel #3
0
 def test(command, options):
     m = Mocker()
     nspb = m.replace(ak, 'NSPasteboard')
     pboard = nspb.pasteboardWithName_(ak.NSFindPboard)
     pboard.availableTypeFromArray_([ak.NSStringPboardType]) >> None
     with m, replace_history() as history:
         fc = FindController()
         sender = Config(selectedItem=lambda: Config(title=lambda: command))
         fc.recentFindSelected_(sender)
         eq_(fc.options._target, options)
Beispiel #4
0
def test_SortLinesController_sort_():
    m = Mocker()
    sort = m.replace(mod, 'sortlines')
    tv = m.mock(TextView)
    with replace_history() as history:
        slc = SortLinesController(tv)
        sort(tv, slc.options)
        m.method(slc.save_options)()
        m.method(slc.cancel_)(None)
        with m:
            slc.sort_(None)
Beispiel #5
0
def test_SortLinesController_sort_():
    m = Mocker()
    sort = m.replace(mod, 'sortlines')
    tv = m.mock(TextView)
    with replace_history() as history:
        slc = SortLinesController(tv)
        sort(tv, slc.options)
        m.method(slc.save_options)()
        m.method(slc.cancel_)(None)
        with m:
            slc.sort_(None)
Beispiel #6
0
 def test(c):
     m = Mocker()
     nspb = m.replace(ak, 'NSPasteboard')
     pboard = nspb.pasteboardWithName_(ak.NSFindPboard)
     pboard.availableTypeFromArray_([ak.NSStringPboardType]) >> (c.ftext is not None)
     if c.ftext is not None:
         pboard.stringForType_(ak.NSStringPboardType) >> c.ftext
     with replace_history() as history:
         if c.hist is not None:
             history.append(c.hist)
         with m:
             fc = FindController() # calls load_options()
             eq_(fc.options._target, FindOptions(**c.opts))
             eq_(fc.options.recent_finds, [] if c.hist is None else [c.hist])
Beispiel #7
0
 def test(c):
     m = Mocker()
     nspb = m.replace(ak, 'NSPasteboard')
     pboard = nspb.pasteboardWithName_(ak.NSFindPboard)
     pboard.availableTypeFromArray_([ak.NSStringPboardType
                                     ]) >> (c.ftext is not None)
     if c.ftext is not None:
         pboard.stringForType_(ak.NSStringPboardType) >> c.ftext
     with replace_history() as history:
         if c.hist is not None:
             history.append(c.hist)
         with m:
             fc = FindController()  # calls load_options()
             eq_(fc.options._target, FindOptions(**c.opts))
             eq_(fc.options.recent_finds,
                 [] if c.hist is None else [c.hist])
Beispiel #8
0
 def test(c):
     m = Mocker()
     with replace_history() as history:
         fc = FindController() # calls load_options()
         fc.options.find_text = "" # clear value from real pasteboard
         fc.options.ignore_case = False
         nspb = m.replace(ak, 'NSPasteboard')
         if "find_text" in c.opts:
             pboard = nspb.pasteboardWithName_(ak.NSFindPboard)
             pboard.declareTypes_owner_([ak.NSStringPboardType], None)
             pboard.setString_forType_(c.opts["find_text"], ak.NSStringPboardType)
         with m:
             for k, v in c.opts.items():
                 setattr(fc.options, k, v)
             print(fc.options._target)
             eq_(fc.save_options(), c.res, fc.options._target)
             eq_(list(history), [] if c.hist is None else [c.hist])
Beispiel #9
0
 def test(c):
     m = Mocker()
     with replace_history() as history:
         fc = FindController()  # calls load_options()
         fc.options.find_text = ""  # clear value from real pasteboard
         fc.options.ignore_case = False
         nspb = m.replace(ak, 'NSPasteboard')
         if "find_text" in c.opts:
             pboard = nspb.pasteboardWithName_(ak.NSFindPboard)
             pboard.declareTypes_owner_([ak.NSStringPboardType], None)
             pboard.setString_forType_(c.opts["find_text"],
                                       ak.NSStringPboardType)
         with m:
             for k, v in c.opts.items():
                 setattr(fc.options, k, v)
             print(fc.options._target)
             eq_(fc.save_options(), c.res, fc.options._target)
             eq_(list(history), [] if c.hist is None else [c.hist])
Beispiel #10
0
 def test(hist, opts):
     with replace_history() as history:
         history.append(hist)
         ctl = SortLinesController(None)
         eq_(ctl.options._target, SortOptions(**opts))
Beispiel #11
0
def test_SortLinesController_default_options():
    with replace_history() as history:
        ctl = SortLinesController(None)
        for name, value in SortOptions.DEFAULTS.items():
            eq_(getattr(ctl.options, name), value, name)
Beispiel #12
0
 def test(hist, opts):
     with replace_history() as history:
         history.append(hist)
         ctl = SortLinesController(None)
         eq_(ctl.options._target, SortOptions(**opts))
Beispiel #13
0
def test_SortLinesController_default_options():
    with replace_history() as history:
        ctl = SortLinesController(None)
        for name, value in SortOptions.DEFAULTS.items():
            eq_(getattr(ctl.options, name), value, name)