[Fixed]-Test case Django command PyCharm

1👍

The best way to do this is to put all of the command logic into a separate function that can be tested independently. Then the command simply calls that function.

If that’s not feasible for some reason you can test a command directly with

from django.core.management import call_command

call_command('my_command', 'foo', bar='baz')

as outlined here:
How can I call a custom Django manage.py command directly from a test driver?

👤rurp

Leave a comment