def test_CommandParser_incomplete(): parser = CommandParser(Choice('arg', 'all')) def check(err): eq_(err.options, Options(arg="arg")) eq_(err.errors, [ParseError("'a' is ambiguous: arg, all", Choice('arg', 'all'), 0, 1)]) with assert_raises(ArgumentError, msg=check): parser.parse('a')
def test_CommandParser_incomplete(): parser = CommandParser(Choice('arg', 'all')) def check(err): eq_(err.options, Options(arg="arg")) eq_(err.errors, [ ParseError("'a' is ambiguous: arg, all", Choice('arg', 'all'), 0, 1) ]) with assert_raises(ArgumentError, msg=check): parser.parse('a')
def test_CommandParser_with_SubParser_errors(): sub = SubArgs("num", Int("num"), abc="xyz") arg = SubParser("var", sub) parser = CommandParser(arg) def check(err): eq_(str(err), "invalid arguments: num x\n" "invalid literal for int() with base 10: 'x'") eq_(err.options, Options(var=None)) eq_(err.errors, [ParseError("invalid literal for int() with base 10: 'x'", Int("num"), 4, 5)]) with assert_raises(ArgumentError, msg=check): parser.parse('num x')
def test_CommandParser_with_SubParser_errors(): sub = SubArgs("num", Int("num"), abc="xyz") arg = SubParser("var", sub) parser = CommandParser(arg) def check(err): eq_( str(err), "invalid arguments: num x\n" "invalid literal for int() with base 10: 'x'") eq_(err.options, Options(var=None)) eq_(err.errors, [ ParseError("invalid literal for int() with base 10: 'x'", Int("num"), 4, 5) ]) with assert_raises(ArgumentError, msg=check): parser.parse('num x')