Does parser type conversion happen inside django tests?

I have defined a custom argument parser

from dateutil.relativedelta import relativedelta

def custom_parser(value):
    # Do some actions with value
    return relativedelta(...)

I the use this in a management command as

parser.add_argument(
            "--tes",
            help=("blablaaa"),
            type=custom_parser,
            required=False,
            default='15s',
        )

Inside the handler, tes is correctly converted If I call the management command from the terminal directly.

def handle(self, *_args, **options):
    tes = options['tes'] 

This is correctly converted to relativedelta when I directly run the command. However, If I run this using call_command('mycommand', tes='20s') options['tes'] is always a string. Why is it not being converted? Can't seem to find something on the codebase that would explain it.

Back to Top