Documentation how to test custom management command missing
The documentation about custom management command misses a few points how to properly test them.
=> https://docs.djangoproject.com/en/1.7/howto/custom-management-commands/
For example the documentation states that you should use self.stdout: "By using these proxies, it becomes much easier to test your custom command"
But how to actually test the output is missing. A complete example with call_command would be great!
Change History
(11)
| Triage Stage: |
Unreviewed → Accepted
|
| Owner: |
changed from nobody to Danilo Bargen
|
| Status: |
new → assigned
|
| Cc: |
mail@… added
|
| Has patch: |
set
|
| Patch needs improvement: |
set
|
| Patch needs improvement: |
unset
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
You can test commands like any other function. Just
from django.core.management import call_command class SomeTest(TestCase): def test_command(self): call_command('your_command', *args, **kwargs) self.assertTrue(somethingDone())and test result or behavior of your command. I think no sense for writing how to test all functions or methods from docs.