Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

pytest for argument parser

I am trying to write pytest case for argument parser. Please see the code below:

def parse_cmd_args():
    """
    add the command line arguments that are to be parsed.
    :param parser: Argument Parser
    :return: the parsed arguments
    """
    cmd_parser = argparse.ArgumentParser(description="testing the cmd_parser")
    cmd_parser.add_argument("name", help="Name to be pulled")
    cmd_parser.add_argument("config", help="path to the configuration file")
    cmd_args = cmd_parser.parse_args()

    return cmd_args

Please help me with the pytest case. I have tried few ways but it didn't give me desired output. Can someone please help me with this

Comments