예제 #1
0
 def test(c):
     m = Mocker()
     tv = m.mock(TextView)
     if c.ind:
         tv.doc_view.document.comment_token >> c.comment
     opts = TestConfig(wrap_column=c.wid, indent=c.ind)
     text = NSString.stringWithString_(c.text)
     sel = (0, len(c.text))
     with m:
         if c._get("debug", False):
             import pdb; pdb.set_trace()
         output = "\n".join(wraplines(iterlines(text, sel), opts, tv))
         eq_(c.result, output)
예제 #2
0
 def test(c):
     m = Mocker()
     opts = "<options>"
     tv = m.mock(TextView)
     ts = tv.textStorage() >> m.mock(NSTextStorage)
     wrap = m.replace(wraplines)
     iterlines = m.replace("editxt.wraplines.iterlines")
     text = tv.string() >> NSString.stringWithString_(c.text)
     sel = (0, len(text)) if c.sel is None else c.sel
     sel = text.lineRangeForRange_(tv.selectedRange() >> sel)
     eol = tv.doc_view.document.eol >> m.mock()
     lines = iterlines(text, sel) >> "<lines>"
     eol.join(wrap(lines, opts, tv) >> [c.result]) >> c.result
     tv.shouldChangeTextInRange_replacementString_(sel, c.result) >> True
     output = []
     def callback(range, text):
         output.append(text)
     expect(ts.replaceCharactersInRange_withString_(sel, c.result)).call(callback)
     tv.didChangeText()
     tv.setSelectedRange_((sel[0], len(c.result)))
     with m:
         wrap_selected_lines(tv, opts)
         eq_(c.result, output[0])