0

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

Giordano
  • 5,094
  • 3
  • 29
  • 48

1 Answers1

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?

Community
  • 1
  • 1
rurp
  • 1,278
  • 2
  • 12
  • 21