Reputation: 5580
I'm a new Pycharm's user, and in my project I created a Django command that needs two parameters. I know that to run it correctly I must add additional options and it works fine.
Now i would like create a test case for it, but i don't know how add additional option in test case.
I should add in Run Configuration or directly in test case? and how?
Thanks in advance
Regards
Upvotes: 0
Views: 81
Reputation: 1456
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?
Upvotes: 1