I am trying to write an unit test for a function that deals with the argparsers from the users.
My function:
def __init_parser() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description='Parsing arguments...',
)
parser.add_argument('--task_id', '-t', dest='task_id', action="store", type=str, required=True)
return parser.parse_args()
Test
@pytest.mark.parametrize('task_id', ('--task_id', '-t'))
def test__init_parser_with_job_id(capsys, task_id):
args = __init_parser()
The error _jb_pytest_runner.py: error: the following arguments are required: --task_id/-t
How can I achieve this passing the number of task_id in the body of the test function?