def test_argument_contains(): argu = Arguments(create_argv(test_command_1)) assert len(argu) == 9 assert argu.contains(['subcmd']) == True assert argu.contains(['subcmd', '-s']) == True assert argu.contains(['subcmd', '-s', '--long']) == True assert argu.contains(['subcmd', '-s', 'lastpos']) == True assert argu.contains(['bogus']) == False # missing argument test returns False assert argu.contains(['subcmd', 'bogus']) == False # if any arguments are missing, returns False
def test_argument_get_arg_position(): argu = Arguments(create_argv(test_command_1)) assert len(argu) == 9 assert argu.get_arg_position("subcmd") == 0 assert argu.get_arg_position("-s") == 1 assert argu.get_arg_position("--long") == 2 assert argu.get_arg_position("lastpos") == 8 with pytest.raises(MissingArgumentError): argu.get_arg_position("bogus")
def test_argument_get_argument_method(): argu = Arguments(create_argv(test_command_1)) assert argu.get_argument(0) == "subcmd" assert argu.get_argument(1) == "-s" assert argu.get_argument(2) == "--long" assert argu.get_argument(7) == "--nameeq=longdefeq" with pytest.raises(IndexOutOfRangeError): argu.get_argument(20) == ""
def test_argument_instantiation(): argu = Arguments(create_argv(test_command_1)) assert len(argu) == 9 assert isinstance(argu, list) assert argu[0] == "subcmd" assert argu[1] == "-s" assert argu[2] == "--long" assert argu[3] == "-n" assert argu[4] == "shortdef" assert argu[5] == "--name" assert argu[6] == "longdef" assert argu[7] == "--nameeq=longdefeq" assert argu[8] == "lastpos"
def test_argument_str_method_empty(): argu = Arguments(create_argv(test_command_empty_1)) assert len(argu) == 0 assert argu.__str__() == "[]"
def test_argument_str_method(): argu = Arguments(create_argv(test_command_2)) assert len(argu) == 2 assert argu.__str__() == "['-s', 'lastpos']"