def testCanParseWithErrors(self): parser = cmd_line.CommandLineParser('10$foo') rv = parser.parse_cmd_line() expected = dict( range=None, commands=[], errors=['E492 Not an editor command.'] ) self.assertEqual(rv, expected)
def testCanParseBangCommand(self): parser = cmd_line.CommandLineParser('!') rv = parser.parse_cmd_line() expected_range = cmd_line.default_range_info.copy() expected = dict( range=expected_range, commands=[{"cmd":"!", "args":"", "forced": False}], errors=[], ) self.assertEqual(rv, expected)
def testCanParseCommandWithArgs(self): parser = cmd_line.CommandLineParser('foo! bar 100') rv = parser.parse_cmd_line() expected_range = cmd_line.default_range_info.copy() expected = dict( range=expected_range, commands=[{"cmd":"foo", "args":"bar 100", "forced": True}], errors=[] ) self.assertEqual(rv, expected)
def testCanParseCommandWithArgsAndRange(self): parser = cmd_line.CommandLineParser('100foo! bar 100') rv = parser.parse_cmd_line() expected_range = cmd_line.default_range_info.copy() expected_range['left_offset'] = 100 expected_range['text_range'] = '100' expected = dict( range=expected_range, commands=[{"cmd":"foo", "args":"bar 100", "forced": True}], errors=[], ) self.assertEqual(rv, expected)