def test(command, expected): m = Mocker() tv = FakeTextView(TEXT) do = CommandTester(mod.sort_lines, textview=tv) with m: do(command) eq_(sort_result(tv.text), expected, TEXT)
def test(c): m = Mocker() beep = m.replace(ak, 'NSBeep') @command(arg_parser=CommandParser( Choice(('selection', True), ('all', False)), Choice(('forward', False), ('reverse xyz', True), name='reverse'), Regex('sort_regex', True), )) def cmd(textview, sender, args): raise NotImplementedError("should not get here") @command(arg_parser=CommandParser( Regex('search_pattern'), Choice(('yes', True), ('no', False)), ), lookup_with_arg_parser=True) def search(textview, sender, args): raise NotImplementedError("should not get here") bar = CommandTester(cmd, search) with m: eq_(bar.get_completions(c.text), c.expect)
def test(c): m = Mocker() beep = m.replace(ak, 'NSBeep') @command(arg_parser=CommandParser( Choice(('selection', True), ('all', False)), Choice(('no', False), ('yes', True)), Regex('sort_regex', True), )) def cmd(textview, sender, args): raise NotImplementedError("should not get here") @command(arg_parser=CommandParser( Regex('search_pattern', replace=c.replace), Choice(('yep', False), ('yes', True)), VarArgs("args", placeholder="..."), ), lookup_with_arg_parser=True) def search(textview, sender, args): raise NotImplementedError("should not get here") bar = CommandTester(cmd, search) with m: eq_(bar.get_placeholder(c.text), c.expect)